From b871f6676eb2552127d7ac931cb638c0dabb1d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 25 Sep 2015 10:57:26 +0100 Subject: [PATCH] fix error handling --- C/absmi.c | 16 +- C/absmi_insts.i | 36 +- C/adtdefs.c | 4 +- C/agc.c | 5 +- C/alloc.c | 860 ++-- C/amasm.c | 50 +- C/arith0.c | 2 +- C/arith1.c | 2 +- C/arith2.c | 2 +- C/arrays.c | 66 +- C/atomic.c | 26 +- C/attvar.c | 20 +- C/bb.c | 8 +- C/bignum.c | 22 +- C/c_interface.c | 42 +- C/cdmgr.c | 56 +- C/compiler.c | 48 +- C/corout.c | 2 +- C/cp_absmi_insts.h | 22 +- C/dbase.c | 3919 ++++++++--------- C/dlmalloc.c | 2 +- C/errors.c | 2322 ++-------- C/exec.c | 12 +- C/exo.c | 4 +- C/flags.c | 2 +- C/globals.c | 30 +- C/gprof.c | 2 +- C/grow.c | 20 +- C/heapgc.c | 6 +- C/index.c | 101 +- C/init.c | 50 +- C/inlines.c | 4 +- C/load_aout.c | 2 +- C/load_coff.c | 2 +- C/load_dl.c | 8 +- C/lu_absmi_insts.h | 16 +- C/prim_absmi_insts.h | 14 +- C/qlyr.c | 2 +- C/save.c | 38 +- C/scanner.c | 36 +- C/signals.c | 2 +- C/sort.c | 2 +- C/stack.c | 436 +- C/stackinfo.c | 4 +- C/stdpreds.c | 10 +- C/text.c | 56 +- C/threads.c | 22 +- C/traced_absmi_insts.h | 22 +- C/udi.c | 2 +- C/unify.c | 2 +- C/utilpreds.c | 78 +- C/write.c | 2 +- CMakeLists.txt.user | 81 +- CXX/yapi.cpp | 2 +- H/YapFlags.h | 208 +- H/YapHandles.h | 155 +- H/Yapproto.h | 8 +- H/clause.h | 4 +- H/iatoms.h | 4 +- H/iswiatoms.h | 2 +- H/rheap.h | 6 +- JIT/HPP/JIT_Compiler.hpp | 2 +- JIT/HPP/indexing_std.h | 2 +- JIT/HPP/indexing_std_d.h | 2 +- JIT/HPP/p_functor.i | 16 +- JIT/HPP/singlecode_misc.h | 50 +- JIT/HPP/singlecode_primitive_predicates.h | 4 +- JIT/HPP/traced_absmi_insts.i | 48 +- JIT/HPP/yaam_call_count.h | 48 +- JIT/HPP/yaam_call_count_d.h | 48 +- JIT/HPP/yaam_misc.h | 2 +- JIT/HPP/yaam_misc_d.h | 2 +- JIT/HPP/yaam_primitive_predicates.h | 12 +- JIT/HPP/yaam_primitive_predicates_d.h | 12 +- JIT/jit_traced.c | 4 +- OPTYap/opt.macros.h | 18 +- OPTYap/opt.preds.c | 4 +- OPTYap/or.copy_engine.c | 2 +- OPTYap/or.cow_engine.c | 2 +- OPTYap/or.memory.c | 48 +- OPTYap/or.sba_engine.c | 2 +- OPTYap/or.thread_engine.c | 2 +- OPTYap/tab.macros.h | 8 +- OPTYap/tab.rational.h | 8 +- OPTYap/tab.tries.c | 4 +- OPTYap/tab.tries.h | 18 +- OPTYap/tab.tries.insts.h | 58 +- OPTYap/traced_tab.tries.insts.h | 10 +- build-distr | 54 - cmake/FindLLVM.cmake | 2 +- cmake/FindMySQL.cmake | 2 +- cmake/FindReadline.cmake | 2 +- cmake/FindSqlite3.cmake | 2 +- cmake/GetGitRevisionDescription.cmake | 2 +- cmake/MacroLogFeature.cmake | 2 +- include/YapError.h | 262 +- include/YapErrors.h | 152 + include/dswiatoms.h | 2 +- library/dialect/swi/fli/swi.c | 4 +- library/dialect/swi/os/pl-error.c | 2 +- library/dialect/swi/os/pl-file.c | 2 +- library/mpi/mpi.c | 6 +- library/system.yap | 68 +- misc/ATOMS | 4 +- misc/SWIATOMS | 2 +- os/chartypes.c | 279 +- os/chartypes.yap | 2 +- os/console.c | 6 +- os/encoding.h | 2 +- os/files.c | 2 +- os/format.c | 6 +- os/iopreds.c | 52 +- os/mem.c | 10 +- os/pipes.c | 14 +- os/readline.c | 2 +- os/readterm.c | 20 +- os/readterm.c.cpp | 8 +- os/readutil.c | 4 +- os/sockets.c | 12 +- os/streams.c | 16 +- os/sysbits.c | 80 +- os/ypsocks.c | 124 +- packages/ProbLog/problog/completion.yap | 2 +- packages/bdd/cmake/FindYAP.cmake | 2 +- .../QCubed.png | Bin 8380 -> 0 bytes .../code.css | 164 - .../ga.js | 66 - .../jquery.js | 96 - .../search.js | 62 - .../style.css | 96 - .../trac(1).css | 121 - .../trac.css | 576 --- .../trac.js | 75 - .../trac_logo_mini.png | Bin 689 -> 0 bytes packages/myddas/myddas_postgres.cc | 2 +- packages/myddas/myddas_sqlite3.c | 2 +- pl/arith.yap | 36 +- pl/messages.yap | 2 +- pl/modules.yap | 12 +- pl/preds.yap | 12 +- pl/profile.yap | 2 +- pl/signals.yap | 2 +- text.cpp | 4 +- utf8proc/utf8proc.c | 4 + utf8proc/utils.cmake | 2 +- 145 files changed, 4466 insertions(+), 7508 deletions(-) delete mode 100644 build-distr create mode 100644 include/YapErrors.h delete mode 100644 packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/QCubed.png delete mode 100644 packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/code.css delete mode 100644 packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/ga.js delete mode 100644 packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/jquery.js delete mode 100644 packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/search.js delete mode 100644 packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/style.css delete mode 100644 packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac(1).css delete mode 100644 packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac.css delete mode 100644 packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac.js delete mode 100644 packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac_logo_mini.png diff --git a/C/absmi.c b/C/absmi.c index a73464c5d..ad9e0c0f7 100755 --- a/C/absmi.c +++ b/C/absmi.c @@ -368,7 +368,7 @@ * Handle overflows when allocating big clauses properly. * * Revision 1.153 2004/11/19 22:08:35 vsc -* replace SYSTEM_ERROR by out OUT_OF_WHATEVER_ERROR whenever appropriate. +* replace SYSTEM_ERROR_INTERNAL by out OUT_OF_WHATEVER_ERROR whenever appropriate. * * Revision 1.152 2004/11/19 17:14:12 vsc * a few fixes for 64 bit compiling. @@ -685,7 +685,7 @@ stack_overflow( PredEntry *pe, CELL *env, yamop *cp USES_REGS, arity_t nargs ) Yap_get_signal( YAP_STOVF_SIGNAL )) { S = (CELL *)pe; if (!Yap_locked_gc(nargs, env, cp)) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); return 0; } return 1; @@ -701,7 +701,7 @@ code_overflow( CELL *yenv USES_REGS ) /* do a garbage collection first to check if we can recover memory */ if (!Yap_locked_growheap(false, 0, NULL)) { - Yap_NilError(OUT_OF_HEAP_ERROR, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_HEAP, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); return 0; } CACHE_A1(); @@ -1110,7 +1110,7 @@ interrupt_deallocate( USES_REGS1 ) return interrupt_handler( pe PASS_REGS ); } if (!Yap_locked_gc(0, ENV, CP)) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); } S = ASP; S[E_CB] = (CELL)(LCL0-cut_b); @@ -1444,7 +1444,7 @@ spy_goal( USES_REGS1 ) PP = NULL; } #endif - Yap_NilError(CALL_COUNTER_UNDERFLOW,""); + Yap_NilError(CALL_COUNTER_UNDERFLOW_EVENT,""); return; } LOCAL_PredEntriesCounter--; @@ -1455,7 +1455,7 @@ spy_goal( USES_REGS1 ) PP = NULL; } #endif - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); return; } if ((pe->PredFlags & (CountPredFlag|ProfiledPredFlag|SpiedPredFlag)) == @@ -1811,7 +1811,7 @@ Yap_absmi(int inp) cut_b = LCL0-(CELL *)(ASP[E_CB]); saveregs(); if(!Yap_growtrail (0, false)) { - Yap_NilError(OUT_OF_TRAIL_ERROR,"YAP failed to reserve %ld bytes in growtrail",sizeof(CELL) * K16); + Yap_NilError(RESOURCE_ERROR_TRAIL,"YAP failed to reserve %ld bytes in growtrail",sizeof(CELL) * K16); setregs(); FAIL(); } @@ -1835,7 +1835,7 @@ Yap_absmi(int inp) #if !USE_THREADED_CODE default: saveregs(); - Yap_Error(SYSTEM_ERROR, MkIntegerTerm(opcode), "trying to execute invalid YAAM instruction %d", opcode); + Yap_Error(SYSTEM_ERROR_INTERNAL, MkIntegerTerm(opcode), "trying to execute invalid YAAM instruction %d", opcode); setregs(); FAIL(); } diff --git a/C/absmi_insts.i b/C/absmi_insts.i index c7b2c84ca..5fa268de3 100644 --- a/C/absmi_insts.i +++ b/C/absmi_insts.i @@ -721,7 +721,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -747,7 +747,7 @@ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { ENV = B->cp_env; saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -783,7 +783,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -827,7 +827,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -869,7 +869,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -921,7 +921,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -1101,16 +1101,16 @@ #if defined(YAPOR) || defined(THREADS) PP = NULL; #endif - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); FAIL(); } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_gc(3, ENV, CP)) { - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); FAIL(); } } @@ -1235,7 +1235,7 @@ PREG = NEXTOP(PREG,Osbpa); saveregs(); if (!Yap_gcl(sz, arity, YENV, PREG)) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); FAIL(); } else { @@ -1334,7 +1334,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -10937,7 +10937,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxx),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -11054,7 +11054,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxc),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -11164,7 +11164,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gc(0, YREG, NEXTOP(NEXTOP(PREG,xxn),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -11271,7 +11271,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxx),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -11398,7 +11398,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxc),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -11526,7 +11526,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxn),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -11902,7 +11902,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP(PREG,e),Osbmp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { diff --git a/C/adtdefs.c b/C/adtdefs.c index 6846d3f11..d1d2ebaab 100755 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -408,7 +408,7 @@ Yap_LookupAtomWithAddress(const char *atom, a = HashChain[hash].Entry; /* search atom in chain */ if (SearchAtom(p, a) != NIL) { - Yap_Error(INTERNAL_ERROR,TermNil,"repeated initialisation for atom %s", ae); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"repeated initialisation for atom %s", ae); WRITE_UNLOCK(HashChain[hash].AERWLock); return; } @@ -1347,7 +1347,7 @@ Yap_GetName(char *s, UInt max, Term t) *s++ = i; t = TailOfTerm(t); if (--max == 0) { - Yap_Error(FATAL_ERROR,t,"not enough space for GetName"); + Yap_Error(SYSTEM_ERROR_FATAL,t,"not enough space for GetName"); } } *s = '\0'; diff --git a/C/agc.c b/C/agc.c index 96bc66055..668508367 100755 --- a/C/agc.c +++ b/C/agc.c @@ -348,7 +348,7 @@ mark_global_cell(CELL *pt) CELL ar[256]; Int i,n = (f)(Yap_BlobTag(t), Yap_BlobInfo(t), ar, 256); if (n < 0) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"not enough space for slot internal variables in agc"); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"not enough space for slot internal variables in agc"); } for (i = 0; i< n; i++) { CELL *pt = ar+i; @@ -360,7 +360,7 @@ mark_global_cell(CELL *pt) if ( (f2 = Yap_blob_gc_relocate_handler(t)) < 0 ) { int out = (f2)(Yap_BlobTag(t), Yap_BlobInfo(t), ar, n); if (out < 0) - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"bad restore of slot internal variables in agc"); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"bad restore of slot internal variables in agc"); } } @@ -436,7 +436,6 @@ clean_atom_list(AtomHashEntry *HashPtr) #ifdef DEBUG_RESTORE3 fprintf(stderr, "Purged %p:%s patm=%p %p\n", at, at->StrOfAE, patm, at->NextOfAE); #endif - GLOBAL_agc_collected += sizeof(AtomEntry)+strlen(at->StrOfAE); GLOBAL_agc_collected += sizeof(AtomEntry)+strlen((const char *)at->StrOfAE); } *patm = atm = at->NextOfAE; diff --git a/C/alloc.c b/C/alloc.c index f4da032ce..d6eae6060 100644 --- a/C/alloc.c +++ b/C/alloc.c @@ -57,7 +57,6 @@ static char SccsId[] = "%W% %G%"; #endif #endif - /************************************************************************/ /* Yap workspace management */ @@ -71,11 +70,10 @@ static char SccsId[] = "%W% %G%"; #define my_realloc0(ptr, sz) Yap_dlrealloc(ptr, sz) #define my_free(sz) Yap_dlfree(sz) -static char * my_realloc(char *ptr, UInt sz, UInt osz, int safe) -{ +static char *my_realloc(char *ptr, UInt sz, UInt osz, int safe) { char *nptr; - restart: +restart: /* simple case */ if (ptr < Yap_HeapBase || ptr > HeapTop) { /* we have enough room */ @@ -117,17 +115,14 @@ static char * my_realloc(char *ptr, UInt sz, UInt osz, int safe) } #endif -#if USE_SYSTEM_MALLOC||USE_DL_MALLOC +#if USE_SYSTEM_MALLOC || USE_DL_MALLOC long long unsigned int mallocs, reallocs, frees; long long unsigned int tmalloc; #undef INSTRUMENT_MALLOC - -static inline char * -call_malloc(size_t size) -{ +static inline char *call_malloc(size_t size) { CACHE_REGS char *out; #if USE_DL_MALLOC @@ -139,9 +134,9 @@ call_malloc(size_t size) size += sizeof(CELL); #endif LOCAL_PrologMode |= MallocMode; - out = (char *) my_malloc(size); + out = (char *)my_malloc(size); #if INSTRUMENT_MALLOC - *(CELL*)out = size-sizeof(CELL); + *(CELL *)out = size - sizeof(CELL); out += sizeof(CELL); #endif LOCAL_PrologMode &= ~MallocMode; @@ -151,16 +146,12 @@ call_malloc(size_t size) return out; } -void * -Yap_AllocCodeSpace(size_t size) -{ +void *Yap_AllocCodeSpace(size_t size) { size = AdjustSize(size); - return call_malloc(size); + return call_malloc(size); } -static inline char * -call_realloc(char *p, size_t size) -{ +static inline char *call_realloc(char *p, size_t size) { CACHE_REGS char *out; #if USE_DL_MALLOC @@ -171,12 +162,12 @@ call_realloc(char *p, size_t size) tmalloc += size; size += sizeof(CELL); p -= sizeof(CELL); - tmalloc -= *(CELL*)p; + tmalloc -= *(CELL *)p; #endif LOCAL_PrologMode |= MallocMode; - out = (char *) my_realloc0(p, size); + out = (char *)my_realloc0(p, size); #if INSTRUMENT_MALLOC - *(CELL*)out = size-sizeof(CELL); + *(CELL *)out = size - sizeof(CELL); out += sizeof(CELL); #endif LOCAL_PrologMode &= ~MallocMode; @@ -186,16 +177,12 @@ call_realloc(char *p, size_t size) return out; } -void * -Yap_ReallocCodeSpace(void *p, size_t size) -{ +void *Yap_ReallocCodeSpace(void *p, size_t size) { size = AdjustSize(size); - return call_realloc(p, size); + return call_realloc(p, size); } -void -Yap_FreeCodeSpace(void *p) -{ +void Yap_FreeCodeSpace(void *p) { CACHE_REGS #if USE_DL_MALLOC LOCK(DLMallocLock); @@ -203,26 +190,22 @@ Yap_FreeCodeSpace(void *p) LOCAL_PrologMode |= MallocMode; #if INSTRUMENT_MALLOC p -= sizeof(CELL); - tmalloc -= *(CELL*)p; + tmalloc -= *(CELL *)p; frees++; #endif - my_free (p); + my_free(p); LOCAL_PrologMode &= ~MallocMode; #if USE_DL_MALLOC UNLOCK(DLMallocLock); #endif } -void * -Yap_AllocAtomSpace(size_t size) -{ +void *Yap_AllocAtomSpace(size_t size) { size = AdjustSize(size); return call_malloc(size); } -void -Yap_FreeAtomSpace(void *p) -{ +void Yap_FreeAtomSpace(void *p) { CACHE_REGS #if USE_DL_MALLOC LOCK(DLMallocLock); @@ -230,10 +213,10 @@ Yap_FreeAtomSpace(void *p) LOCAL_PrologMode |= MallocMode; #if INSTRUMENT_MALLOC p -= sizeof(CELL); - tmalloc -= *(CELL*)p; + tmalloc -= *(CELL *)p; frees++; #endif - my_free (p); + my_free(p); LOCAL_PrologMode &= ~MallocMode; #if USE_DL_MALLOC UNLOCK(DLMallocLock); @@ -244,14 +227,11 @@ Yap_FreeAtomSpace(void *p) /* If you need to dinamically allocate space from the heap, this is * the macro you should use */ -ADDR -Yap_InitPreAllocCodeSpace(int wid) -{ +ADDR Yap_InitPreAllocCodeSpace(int wid) { CACHE_REGS char *ptr; UInt sz = REMOTE_ScratchPad(wid).msz; - if (REMOTE_ScratchPad(wid).ptr == NULL) { #if USE_DL_MALLOC LOCK(DLMallocLock); @@ -262,24 +242,24 @@ Yap_InitPreAllocCodeSpace(int wid) tmalloc += sz; sz += sizeof(CELL); #endif - while (!(ptr = + while (!(ptr = #ifdef YAPOR_COPY - malloc(sz) + malloc(sz) #else - my_malloc(sz) + my_malloc(sz) #endif - )) { + )) { REMOTE_PrologMode(wid) &= ~MallocMode; #if USE_DL_MALLOC UNLOCK(DLMallocLock); #endif if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); - return(NULL); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); + return (NULL); } #if INSTRUMENT_MALLOC sz -= sizeof(CELL); - *(CELL*)ptr = sz; + *(CELL *)ptr = sz; ptr += sizeof(CELL); #endif #if USE_DL_MALLOC @@ -296,23 +276,21 @@ Yap_InitPreAllocCodeSpace(int wid) ptr = REMOTE_ScratchPad(wid).ptr; } AuxBase = (ADDR)(ptr); - AuxSp = (CELL *)(AuxTop = AuxBase+REMOTE_ScratchPad(wid).sz); + AuxSp = (CELL *)(AuxTop = AuxBase + REMOTE_ScratchPad(wid).sz); return ptr; } -ADDR -Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe) -{ +ADDR Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe) { CACHE_REGS char *ptr; UInt sz = LOCAL_ScratchPad.msz; if (sz0 < SCRATCH_INC_SIZE) sz0 = SCRATCH_INC_SIZE; if (sz0 < LOCAL_ScratchPad.sz) - sz = LOCAL_ScratchPad.sz+sz0; - else + sz = LOCAL_ScratchPad.sz + sz0; + else sz = sz0; - sz = AdjustLargePageSize(sz+sz/4); + sz = AdjustLargePageSize(sz + sz / 4); #if USE_DL_MALLOC LOCK(DLMallocLock); @@ -323,7 +301,8 @@ Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe) tmalloc -= LOCAL_ScratchPad.sz; tmalloc += sz; #endif - if (!(ptr = my_realloc(LOCAL_ScratchPad.ptr, sz, LOCAL_ScratchPad.sz, safe))) { + if (!(ptr = + my_realloc(LOCAL_ScratchPad.ptr, sz, LOCAL_ScratchPad.sz, safe))) { LOCAL_PrologMode &= ~MallocMode; #if USE_DL_MALLOC UNLOCK(DLMallocLock); @@ -337,7 +316,7 @@ Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe) LOCAL_ScratchPad.sz = LOCAL_ScratchPad.msz = sz; LOCAL_ScratchPad.ptr = ptr; AuxBase = ptr; - AuxSp = (CELL *)(AuxTop = ptr+sz); + AuxSp = (CELL *)(AuxTop = ptr + sz); return ptr; } @@ -345,23 +324,18 @@ Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe) struct various_codes *Yap_heap_regs; -static void -InitHeap(void) -{ - Yap_heap_regs = (struct various_codes *)calloc(1, sizeof(struct various_codes)); +static void InitHeap(void) { + Yap_heap_regs = + (struct various_codes *)calloc(1, sizeof(struct various_codes)); } -void -Yap_InitHeap(void *heap_addr) -{ +void Yap_InitHeap(void *heap_addr) { InitHeap(); Yap_HoleSize = 0; HeapMax = 0; } -static void -InitExStacks(int wid, int Trail, int Stack) -{ +static void InitExStacks(int wid, int Trail, int Stack) { CACHE_REGS UInt pm, sa; @@ -370,12 +344,12 @@ InitExStacks(int wid, int Trail, int Stack) Trail = MinTrailSpace; if (Stack < MinStackSpace) Stack = MinStackSpace; - pm = (Trail + Stack)*K; /* memory to be - * requested */ - sa = Stack*K; /* stack area size */ + pm = (Trail + Stack) * K; /* memory to be + * requested */ + sa = Stack * K; /* stack area size */ #ifdef THREADS - if (wid) + if (wid) REMOTE_GlobalBase(wid) = (ADDR)REMOTE_ThreadHandle(wid).stack_address; else AuxSp = NULL; @@ -391,26 +365,25 @@ InitExStacks(int wid, int Trail, int Stack) if (Yap_output_msg) { UInt ta; - fprintf(stderr, "HeapBase = %p GlobalBase = %p\n LocalBase = %p TrailTop = %p\n", - Yap_HeapBase, REMOTE_GlobalBase(wid), REMOTE_LocalBase(wid), REMOTE_TrailTop(wid)); + fprintf(stderr, + "HeapBase = %p GlobalBase = %p\n LocalBase = %p TrailTop = %p\n", + Yap_HeapBase, REMOTE_GlobalBase(wid), REMOTE_LocalBase(wid), + REMOTE_TrailTop(wid)); - ta = Trail*K; /* trail area size */ + ta = Trail * K; /* trail area size */ fprintf(stderr, "Heap+Aux: %lu\tLocal+Global: %lu\tTrail: %lu\n", - (long unsigned)(pm - sa - ta), (long unsigned)sa, (long unsigned)ta); + (long unsigned)(pm - sa - ta), (long unsigned)sa, + (long unsigned)ta); } #endif /* DEBUG */ } -void -Yap_InitExStacks(int wid, int Trail, int Stack) -{ +void Yap_InitExStacks(int wid, int Trail, int Stack) { InitExStacks(wid, Trail, Stack); } #if defined(THREADS) -void -Yap_KillStacks(int wid) -{ +void Yap_KillStacks(int wid) { ADDR gb = REMOTE_ThreadHandle(wid).stack_address; if (gb) { free(gb); @@ -418,9 +391,7 @@ Yap_KillStacks(int wid) } } #else -void -Yap_KillStacks(int wid) -{ +void Yap_KillStacks(int wid) { if (LOCAL_GlobalBase) { free(LOCAL_GlobalBase); LOCAL_GlobalBase = NULL; @@ -428,20 +399,14 @@ Yap_KillStacks(int wid) } #endif -void -Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) -{ - InitHeap(); -} +void Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) { InitHeap(); } -int -Yap_ExtendWorkSpace(Int s) -{ +int Yap_ExtendWorkSpace(Int s) { CACHE_REGS void *basebp = LOCAL_GlobalBase, *nbp; - UInt s0 = LOCAL_TrailTop- LOCAL_GlobalBase; - nbp = realloc(basebp, s+s0); - if (nbp == NULL) + UInt s0 = LOCAL_TrailTop - LOCAL_GlobalBase; + nbp = realloc(basebp, s + s0); + if (nbp == NULL) return FALSE; #if defined(THREADS) LOCAL_ThreadHandle.stack_address = (char *)nbp; @@ -450,37 +415,27 @@ Yap_ExtendWorkSpace(Int s) return TRUE; } -size_t -Yap_ExtendWorkSpaceThroughHole(size_t s) -{ - return 0; -} +size_t Yap_ExtendWorkSpaceThroughHole(size_t s) { return 0; } -void -Yap_AllocHole(UInt actual_request, UInt total_size) -{ -} +void Yap_AllocHole(UInt actual_request, UInt total_size) {} #if HAVE_MALLINFO -UInt -Yap_givemallinfo(void) -{ +UInt Yap_givemallinfo(void) { struct mallinfo mi = mallinfo(); return mi.uordblks; } #endif - #else #if HAVE_SNPRINTF -#define snprintf3(A,B,C) snprintf(A,B,C) -#define snprintf4(A,B,C,D) snprintf(A,B,C,D) -#define snprintf5(A,B,C,D,E) snprintf(A,B,C,D,E) +#define snprintf3(A, B, C) snprintf(A, B, C) +#define snprintf4(A, B, C, D) snprintf(A, B, C, D) +#define snprintf5(A, B, C, D, E) snprintf(A, B, C, D, E) #else -#define snprintf3(A,B,C) sprintf(A,C) -#define snprintf4(A,B,C,D) sprintf(A,C,D) -#define snprintf5(A,B,C,D,E) sprintf(A,C,D,E) +#define snprintf3(A, B, C) sprintf(A, C) +#define snprintf4(A, B, C, D) sprintf(A, C, D) +#define snprintf5(A, B, C, D, E) sprintf(A, C, D, E) #endif #ifdef LIGHT @@ -495,11 +450,9 @@ static char *AllocHeap(unsigned long int); static void RemoveFromFreeList(BlockHeader *); static void AddToFreeList(BlockHeader *); -#define MinHGap 256*K +#define MinHGap 256 * K -static void -RemoveFromFreeList(BlockHeader *b) -{ +static void RemoveFromFreeList(BlockHeader *b) { BlockHeader *p; p = b->b_next_size; @@ -512,8 +465,7 @@ RemoveFromFreeList(BlockHeader *b) p->b_next = b; if (b) b->b_next_size = p; - } - else { + } else { BlockHeader **q = &FreeBlocks; while ((*q) != b) @@ -522,16 +474,13 @@ RemoveFromFreeList(BlockHeader *b) p = b->b_next; *q = p; p->b_next_size = b->b_next_size; - } - else { + } else { *q = b->b_next_size; } } } -static void -AddToFreeList(BlockHeader *b) -{ +static void AddToFreeList(BlockHeader *b) { BlockHeader **q, *p; YAP_SEG_SIZE *sp; @@ -549,23 +498,20 @@ AddToFreeList(BlockHeader *b) b->b_next = p; b->b_next_size = p->b_next_size; p->b_next_size = b; - } - else { + } else { b->b_next = NIL; b->b_next_size = p; } *q = b; } -static void -FreeBlock(BlockHeader *b) -{ +static void FreeBlock(BlockHeader *b) { BlockHeader *p; YAP_SEG_SIZE *sp; /* { static long long int vsc_free_ops; - + vsc_free_ops++; BlockHeader *q = FreeBlocks; while (q) q = q->b_next_size; @@ -575,11 +521,15 @@ FreeBlock(BlockHeader *b) sp = &(b->b_size) + (b->b_size & ~InUseFlag); if (!(b->b_size & InUseFlag) || *sp != b->b_size) { #if !SHORT_INTS - fprintf(stderr, "%% YAP INTERNAL ERROR: sanity check failed in FreeBlock %p %x %x\n", - b, b->b_size, Unsigned(*sp)); + fprintf( + stderr, + "%% YAP INTERNAL ERROR: sanity check failed in FreeBlock %p %x %x\n", b, + b->b_size, Unsigned(*sp)); #else - fprintf(stderr, "%% YAP INTERNAL ERROR: sanity check failed in FreeBlock %p %lx %lx\n", - b, b->b_size, *sp); + fprintf( + stderr, + "%% YAP INTERNAL ERROR: sanity check failed in FreeBlock %p %lx %lx\n", + b, b->b_size, *sp); #endif return; } @@ -588,16 +538,16 @@ FreeBlock(BlockHeader *b) /* check if we can collapse with other blocsks */ /* check previous */ sp = &(b->b_size) - 1; - if (!(*sp & InUseFlag)) { /* previous block is free */ - p = (BlockHeader *) (sp - *sp); + if (!(*sp & InUseFlag)) { /* previous block is free */ + p = (BlockHeader *)(sp - *sp); RemoveFromFreeList(p); p->b_size += b->b_size + 1; b = p; } /* check following */ sp = &(b->b_size) + b->b_size + 1; - if (!(*sp & InUseFlag)) { /* following block is free */ - p = (BlockHeader *) sp; + if (!(*sp & InUseFlag)) { /* following block is free */ + p = (BlockHeader *)sp; RemoveFromFreeList(p); b->b_size += p->b_size + 1; } @@ -607,9 +557,9 @@ FreeBlock(BlockHeader *b) HeapUsed -= (b->b_size + 1) * sizeof(YAP_SEG_SIZE); UNLOCK(HeapUsedLock); HeapTop = (ADDR)b; - *((YAP_SEG_SIZE *) HeapTop) = InUseFlag; + *((YAP_SEG_SIZE *)HeapTop) = InUseFlag; } else { - /* insert on list of free blocks */ + /* insert on list of free blocks */ AddToFreeList(b); } UNLOCK(HeapTopLock); @@ -617,8 +567,7 @@ FreeBlock(BlockHeader *b) } static BlockHeader * -GetBlock(unsigned long int n) -{ /* get free block with size at least n */ +GetBlock(unsigned long int n) { /* get free block with size at least n */ register BlockHeader **p, *b, *r; if (FreeBlocks == NIL) @@ -645,9 +594,7 @@ GetBlock(unsigned long int n) return (b); } -static char * -AllocHeap(unsigned long int size) -{ +static char *AllocHeap(unsigned long int size) { BlockHeader *b, *n; YAP_SEG_SIZE *sp; UInt align, extra; @@ -659,24 +606,25 @@ AllocHeap(unsigned long int size) while (q) q = q->b_next_size; }*/ - extra = size/16; -#if SIZEOF_INT_P==4 - align = 2*sizeof(CELL); /* size in dwords + 2 */ + extra = size / 16; +#if SIZEOF_INT_P == 4 + align = 2 * sizeof(CELL); /* size in dwords + 2 */ #endif -#if SIZEOF_INT_P==8 +#if SIZEOF_INT_P == 8 align = sizeof(CELL); #endif - while (align < extra) align *= 2; - size = ALIGN_SIZE(size,align); + while (align < extra) + align *= 2; + size = ALIGN_SIZE(size, align); if (size < sizeof(BlockHeader)) size = sizeof(BlockHeader); size += sizeof(YAP_SEG_SIZE); /* change units to cells */ - size = size/sizeof(CELL); + size = size / sizeof(CELL); LOCK(FreeBlocksLock); if ((b = GetBlock(size))) { - if (b->b_size >= size+24+1) { - n = (BlockHeader *) (((YAP_SEG_SIZE *) b) + size + 1); + if (b->b_size >= size + 24 + 1) { + n = (BlockHeader *)(((YAP_SEG_SIZE *)b) + size + 1); n->b_size = b->b_size - size - 1; b->b_size = size; AddToFreeList(n); @@ -689,14 +637,14 @@ AllocHeap(unsigned long int size) } LOCK(HeapTopLock); UNLOCK(FreeBlocksLock); - b = (BlockHeader *) HeapTop; + b = (BlockHeader *)HeapTop; HeapTop += size * sizeof(CELL) + sizeof(YAP_SEG_SIZE); LOCK(HeapUsedLock); HeapUsed += size * sizeof(CELL) + sizeof(YAP_SEG_SIZE); #ifdef YAPOR if (HeapTop > Addr(LOCAL_GlobalBase) - MinHeapGap) - Yap_Error(INTERNAL_ERROR, TermNil, "no heap left (AllocHeap)"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "no heap left (AllocHeap)"); #else if (HeapTop > HeapLim - MinHeapGap) { HeapTop -= size * sizeof(CELL) + sizeof(YAP_SEG_SIZE); @@ -705,28 +653,28 @@ AllocHeap(unsigned long int size) UNLOCK(HeapUsedLock); UNLOCK(HeapTopLock); /* we destroyed the stack */ - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "Stack Crashed against Heap..."); - return(NULL); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "Stack Crashed against Heap..."); + return (NULL); } else { if (HeapTop + size * sizeof(CELL) + sizeof(YAP_SEG_SIZE) < HeapLim) { - /* small allocations, we can wait */ - HeapTop += size * sizeof(CELL) + sizeof(YAP_SEG_SIZE); - HeapUsed += size * sizeof(CELL) + sizeof(YAP_SEG_SIZE); - UNLOCK(HeapUsedLock); - UNLOCK(HeapTopLock); - Yap_signal(YAP_CDOVF_SIGNAL); + /* small allocations, we can wait */ + HeapTop += size * sizeof(CELL) + sizeof(YAP_SEG_SIZE); + HeapUsed += size * sizeof(CELL) + sizeof(YAP_SEG_SIZE); + UNLOCK(HeapUsedLock); + UNLOCK(HeapTopLock); + Yap_signal(YAP_CDOVF_SIGNAL); } else { - if (size > GLOBAL_SizeOfOverflow) - GLOBAL_SizeOfOverflow = size*sizeof(CELL) + sizeof(YAP_SEG_SIZE); - /* big allocations, the caller must handle the problem */ - UNLOCK(HeapUsedLock); - UNLOCK(HeapTopLock); - return(NULL); + if (size > GLOBAL_SizeOfOverflow) + GLOBAL_SizeOfOverflow = size * sizeof(CELL) + sizeof(YAP_SEG_SIZE); + /* big allocations, the caller must handle the problem */ + UNLOCK(HeapUsedLock); + UNLOCK(HeapTopLock); + return (NULL); } } } #endif /* YAPOR */ - *((YAP_SEG_SIZE *) HeapTop) = InUseFlag; + *((YAP_SEG_SIZE *)HeapTop) = InUseFlag; if (HeapUsed > HeapMax) HeapMax = HeapUsed; UNLOCK(HeapUsedLock); @@ -739,70 +687,58 @@ AllocHeap(unsigned long int size) /* If you need to dinamically allocate space from the heap, this is * the macro you should use */ -static void -FreeCodeSpace(char *p) -{ - FreeBlock(((BlockHeader *) (p - sizeof(YAP_SEG_SIZE)))); +static void FreeCodeSpace(char *p) { + FreeBlock(((BlockHeader *)(p - sizeof(YAP_SEG_SIZE)))); } -static char * -AllocCodeSpace(unsigned long int size) -{ +static char *AllocCodeSpace(unsigned long int size) { if (size < SmallSize + 2 * OpCodeSize + 3 * CellSize) return (AllocHeap(SmallSize + 2 * OpCodeSize + 3 * CellSize)); return (AllocHeap(size)); } - #if DEBUG_ALLOC int vsc_mem_trace; #endif /* If you need to dinamically allocate space from the heap, this is * the macro you should use */ -void -Yap_FreeCodeSpace(char *p) -{ +void Yap_FreeCodeSpace(char *p) { #if DEBUG_ALLOC if (vsc_mem_trace) - printf("-%p\n",p); + printf("-%p\n", p); #endif FreeCodeSpace(p); } -char * -Yap_AllocAtomSpace(unsigned long int size) -{ +char *Yap_AllocAtomSpace(unsigned long int size) { char *out = AllocHeap(size); #if DEBUG_ALLOC - if (vsc_mem_trace) printf("+%p/%d\n",out,size); + if (vsc_mem_trace) + printf("+%p/%d\n", out, size); #endif return out; } -void -Yap_FreeAtomSpace(char *p) -{ +void Yap_FreeAtomSpace(char *p) { #if DEBUG_ALLOC if (vsc_mem_trace) - printf("-%p\n",p); + printf("-%p\n", p); #endif FreeCodeSpace(p); } -char * -Yap_AllocCodeSpace(unsigned long int size) -{ +char *Yap_AllocCodeSpace(unsigned long int size) { char *out = AllocCodeSpace(size); #if DEBUG_ALLOC - if (vsc_mem_trace) printf("+%p/%d\n",out,size); + if (vsc_mem_trace) + printf("+%p/%d\n", out, size); #endif return out; } #endif - /************************************************************************/ /* Workspace allocation */ /* */ @@ -827,16 +763,15 @@ Yap_AllocCodeSpace(unsigned long int size) static LPVOID brk; -static int -ExtendWorkSpace(Int s, int fixed_allocation) -{ +static int ExtendWorkSpace(Int s, int fixed_allocation) { LPVOID b = brk; prolog_exec_mode OldPrologMode = LOCAL_PrologMode; LOCAL_PrologMode = ExtendStackMode; #if DEBUG_WIN32_ALLOC - fprintf(stderr,"trying: %p (" Int_FORMAT "K) %d\n",b, s/1024, fixed_allocation); + fprintf(stderr, "trying: %p (" Int_FORMAT "K) %d\n", b, s / 1024, + fixed_allocation); #endif if (fixed_allocation) { b = VirtualAlloc(b, s, MEM_RESERVE, PAGE_NOACCESS); @@ -852,10 +787,9 @@ ExtendWorkSpace(Int s, int fixed_allocation) { char msg[256]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), msg, 256, - NULL); - fprintf(stderr,"NOT OK1: %p %p %s\n", brk, b, msg); + NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), msg, 256, NULL); + fprintf(stderr, "NOT OK1: %p %p %s\n", brk, b, msg); } #endif return FALSE; @@ -864,41 +798,34 @@ ExtendWorkSpace(Int s, int fixed_allocation) if (!b) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "VirtualAlloc could not commit %ld bytes", - (long int)s); + "VirtualAlloc could not commit %ld bytes", (long int)s); LOCAL_PrologMode = OldPrologMode; #if DEBUG_WIN32_ALLOC - fprintf(stderr,"NOT OK2: %p--%p\n",b,brk); + fprintf(stderr, "NOT OK2: %p--%p\n", b, brk); #endif return FALSE; } - brk = (LPVOID) ((Int) b + s); + brk = (LPVOID)((Int)b + s); #if DEBUG_WIN32_ALLOC - fprintf(stderr,"OK: %p--%p " Int_FORMAT "\n",b, brk, s); + fprintf(stderr, "OK: %p--%p " Int_FORMAT "\n", b, brk, s); #endif LOCAL_PrologMode = OldPrologMode; return TRUE; } -static MALLOC_T -InitWorkSpace(Int s) -{ +static MALLOC_T InitWorkSpace(Int s) { SYSTEM_INFO si; Int psz; GetSystemInfo(&si); psz = Yap_page_size = si.dwPageSize; brk = (LPVOID)psz; - if (!ExtendWorkSpace(s,0)) + if (!ExtendWorkSpace(s, 0)) return FALSE; - return (MALLOC_T)brk-s; + return (MALLOC_T)brk - s; } -int -Yap_FreeWorkSpace(void) -{ - return TRUE; -} +int Yap_FreeWorkSpace(void) { return TRUE; } #elif USE_SYSTEM_MMAP @@ -925,46 +852,49 @@ Yap_FreeWorkSpace(void) static MALLOC_T WorkSpaceTop; -static MALLOC_T -InitWorkSpace(Int s) -{ +static MALLOC_T InitWorkSpace(Int s) { MALLOC_T a; -#if !defined(_AIX) && !defined(__APPLE__) && !__hpux +#if !defined(_AIX) && !defined(__APPLE__) && !__hpux int fd; #endif #if defined(_AIX) - a = mmap(0, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_VARIABLE, -1, 0); + a = mmap(0, (size_t)s, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_VARIABLE, -1, 0); #elif __hpux - a = mmap(((void *)MMAP_ADDR), (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + a = mmap(((void *)MMAP_ADDR), (size_t)s, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); if (a != (MALLOC_T)MMAP_ADDR) { - Yap_Error(FATAL_ERROR, TermNil, "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR, a); - return(NULL); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, + "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR, a); + return (NULL); } #elif defined(__APPLE__) #ifdef MMAP_ADDR - a = mmap(((void *)MMAP_ADDR), (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0); + a = mmap(((void *)MMAP_ADDR), (size_t)s, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0); if (a != (MALLOC_T)MMAP_ADDR) { - Yap_Error(FATAL_ERROR, TermNil, "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR,a ); - return(NULL); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, + "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR, a); + return (NULL); } #else - a = mmap(NULL, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_ANON, -1, 0); + a = mmap(NULL, (size_t)s, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANON, -1, 0); #endif #else fd = open("/dev/zero", O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { #if HAVE_MKSTEMP char file[256]; - strncpy(file,"/tmp/YAP.TMPXXXXXX", 256); + strncpy(file, "/tmp/YAP.TMPXXXXXX", 256); if (mkstemp(file) == -1) { #if HAVE_STRERROR - Yap_Error(FATAL_ERROR, TermNil, "mkstemp could not create temporary file %s (%s)", file, strerror(errno)); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, + "mkstemp could not create temporary file %s (%s)", file, + strerror(errno)); #else - Yap_Error(FATAL_ERROR, TermNil, "mkstemp could not create temporary file %s", file); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, + "mkstemp could not create temporary file %s", file); #endif return NULL; } @@ -973,154 +903,159 @@ InitWorkSpace(Int s) char *file = tmpnam(NULL); #else char file[YAP_FILENAME_MAX]; - strcpy(file,"/tmp/mapfile"); + strcpy(file, "/tmp/mapfile"); itos(getpid(), &file[12]); #endif /* HAVE_TMPNAM */ #endif /* HAVE_MKSTEMP */ - fd = open(file, O_CREAT|O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + fd = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { - Yap_Error(FATAL_ERROR, TermNil, "mmap could not open %s", file); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "mmap could not open %s", file); return NULL; } if (lseek(fd, s, SEEK_SET) < 0) { - Yap_Error(FATAL_ERROR, TermNil, "mmap could not lseek in mmapped file %s", file); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, + "mmap could not lseek in mmapped file %s", file); close(fd); return FALSE; } if (write(fd, "", 1) < 0) { - Yap_Error(FATAL_ERROR, TermNil, "mmap could not write in mmapped file %s", file); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, + "mmap could not write in mmapped file %s", file); close(fd); return NULL; } if (unlink(file) < 0) { - Yap_Error(FATAL_ERROR,TermNil, "mmap could not unlink mmapped file %s", file); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, + "mmap could not unlink mmapped file %s", file); close(fd); return NULL; } } #if USE_FIXED - a = mmap(((void *)MMAP_ADDR), (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_FIXED, fd, 0); + a = mmap(((void *)MMAP_ADDR), (size_t)s, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_FIXED, fd, 0); if (a != (MALLOC_T)MMAP_ADDR) { - Yap_Error(FATAL_ERROR, TermNil, "mmap could not map at %p, got %p", (void *)MMAP_ADDR, a); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "mmap could not map at %p, got %p", + (void *)MMAP_ADDR, a); return NULL; } #else - a = mmap(0, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE, fd, 0); + a = mmap(0, (size_t)s, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, + 0); if ((CELL)a & YAP_PROTECTED_MASK) { close(fd); - Yap_Error(FATAL_ERROR, TermNil, "mmapped address %p collides with YAP tags", a); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, + "mmapped address %p collides with YAP tags", a); return NULL; } if (close(fd) == -1) { - Yap_Error(FATAL_ERROR, TermNil, "while closing mmaped file"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "while closing mmaped file"); return NULL; } #endif #endif if #ifdef MMAP_FAILED - (a == (MALLOC_T) MMAP_FAILED) + (a == (MALLOC_T)MMAP_FAILED) #else - (a == (MALLOC_T) - 1) + (a == (MALLOC_T)-1) #endif - { - Yap_Error(FATAL_ERROR, TermNil, "mmap cannot allocate memory ***"); - return(NULL); - } - WorkSpaceTop = (char *) a + s; - return (void *) a; + { + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "mmap cannot allocate memory ***"); + return (NULL); + } + WorkSpaceTop = (char *)a + s; + return (void *)a; } - #ifndef YAPOR -static MALLOC_T -mmap_extension(Int s, MALLOC_T base, int fixed_allocation) -{ +static MALLOC_T mmap_extension(Int s, MALLOC_T base, int fixed_allocation) { MALLOC_T a; #if !defined(_AIX) && !defined(__hpux) && !defined(__APPLE__) - int fd; + int fd; #endif #if defined(_AIX) || defined(__hpux) - a = mmap(base, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + a = mmap(base, (size_t)s, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); #elif defined(__APPLE__) - a = mmap(base, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_ANON | fixed_allocation, -1, 0); + a = mmap(base, (size_t)s, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANON | fixed_allocation, -1, 0); #else - fd = open("/dev/zero", O_RDWR); - if (fd < 0) { + fd = open("/dev/zero", O_RDWR); + if (fd < 0) { #if HAVE_MKSTEMP - char file[256]; - strncpy(file,"/tmp/YAP.TMPXXXXXX",256); - if (mkstemp(file) == -1) { - LOCAL_ErrorMessage = LOCAL_ErrorSay; + char file[256]; + strncpy(file, "/tmp/YAP.TMPXXXXXX", 256); + if (mkstemp(file) == -1) { + LOCAL_ErrorMessage = LOCAL_ErrorSay; #if HAVE_STRERROR - snprintf5(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "mkstemp could not create temporary file %s (%s)", - file, strerror(errno)); + snprintf5(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, + "mkstemp could not create temporary file %s (%s)", file, + strerror(errno)); #else - snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "mkstemp could not create temporary file %s", file); + snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, + "mkstemp could not create temporary file %s", file); #endif /* HAVE_STRERROR */ - return (MALLOC_T)-1; - } + return (MALLOC_T)-1; + } #else #if HAVE_TMPNAM - char *file = tmpnam(NULL); + char *file = tmpnam(NULL); #else - char file[YAP_FILENAME_MAX]; - strcpy(file,"/tmp/mapfile"); - itos(getpid(), &file[12]); + char file[YAP_FILENAME_MAX]; + strcpy(file, "/tmp/mapfile"); + itos(getpid(), &file[12]); #endif /* HAVE_TMPNAM */ #endif /* HAVE_MKSTEMP */ - fd = open(file, O_CREAT|O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + fd = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "mmap could not open %s", file); + "mmap could not open %s", file); return (MALLOC_T)-1; } if (lseek(fd, s, SEEK_SET) < 0) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "mmap could not lseek in mmapped file %s", file); + "mmap could not lseek in mmapped file %s", file); close(fd); return (MALLOC_T)-1; } if (write(fd, "", 1) < 0) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "mmap could not write in mmapped file %s", file); + "mmap could not write in mmapped file %s", file); close(fd); return (MALLOC_T)-1; } if (unlink(file) < 0) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "mmap could not unlink mmapped file %s", file); + "mmap could not unlink mmapped file %s", file); close(fd); return (MALLOC_T)-1; } } - a = mmap(base, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE + a = mmap( + base, (size_t)s, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE #if !defined(__linux) - /* use MAP_FIXED, otherwise God knows where you will be placed */ - |fixed_allocation + /* use MAP_FIXED, otherwise God knows where you will be placed */ + | + fixed_allocation #endif - , fd, 0); + , + fd, 0); if (close(fd) == -1) { LOCAL_ErrorMessage = LOCAL_ErrorSay; #if HAVE_STRERROR snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "mmap could not close file (%s) ]\n", strerror(errno)); + "mmap could not close file (%s) ]\n", strerror(errno)); #else snprintf3(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "mmap could not close file ]\n"); + "mmap could not close file ]\n"); #endif return (MALLOC_T)-1; } @@ -1129,20 +1064,18 @@ mmap_extension(Int s, MALLOC_T base, int fixed_allocation) } #endif /* !YAPOR */ - /* - s= how much memory we need; + s= how much memory we need; fixed_alloc = do we need to contiguously extend stack returns TRUE or FALSE updates WorkSpaceTop */ -static int -ExtendWorkSpace(Int s, int fixed_allocation) -{ +static int ExtendWorkSpace(Int s, int fixed_allocation) { #ifdef YAPOR - Yap_Error(INTERNAL_ERROR, TermNil, "cannot extend stacks (ExtendWorkSpace)"); - return(FALSE); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "cannot extend stacks (ExtendWorkSpace)"); + return (FALSE); #else MALLOC_T a; prolog_exec_mode OldPrologMode = LOCAL_PrologMode; @@ -1155,14 +1088,14 @@ ExtendWorkSpace(Int s, int fixed_allocation) LOCAL_PrologMode = ExtendStackMode; a = mmap_extension(s, base, fixed_allocation); LOCAL_PrologMode = OldPrologMode; - if (a == (MALLOC_T) - 1) { + if (a == (MALLOC_T)-1) { LOCAL_ErrorMessage = LOCAL_ErrorSay; #if HAVE_STRERROR snprintf5(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "could not allocate %d bytes (%s)", (int)s, strerror(errno)); + "could not allocate %d bytes (%s)", (int)s, strerror(errno)); #else snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "could not allocate %d bytes", (int)s); + "could not allocate %d bytes", (int)s); #endif return FALSE; } @@ -1171,7 +1104,7 @@ ExtendWorkSpace(Int s, int fixed_allocation) munmap((void *)a, (size_t)s); LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf5(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "mmap could not grow memory at %p, got %p", WorkSpaceTop, a ); + "mmap could not grow memory at %p, got %p", WorkSpaceTop, a); LOCAL_PrologMode = OldPrologMode; return FALSE; } @@ -1182,17 +1115,13 @@ ExtendWorkSpace(Int s, int fixed_allocation) munmap(a, s); return res; } - WorkSpaceTop = (char *) a + s; + WorkSpaceTop = (char *)a + s; LOCAL_PrologMode = OldPrologMode; return TRUE; #endif /* YAPOR */ } -int -Yap_FreeWorkSpace(void) -{ - return 1; -} +int Yap_FreeWorkSpace(void) { return 1; } #elif USE_SYSTEM_SHM @@ -1206,69 +1135,62 @@ Yap_FreeWorkSpace(void) static MALLOC_T WorkSpaceTop; -static MALLOC_T -InitWorkSpace(Int s) -{ +static MALLOC_T InitWorkSpace(Int s) { MALLOC_T ptr; int shm_id; /* mapping heap area */ - if((shm_id = shmget(IPC_PRIVATE, (size_t)s, SHM_R|SHM_W)) == -1) { - Yap_Error(FATAL_ERROR, TermNil, "could not shmget %d bytes", s); - return(NULL); - } - if((ptr = (MALLOC_T)shmat(shm_id, (void *) MMAP_ADDR, 0)) == (MALLOC_T) -1) { - Yap_Error(FATAL_ERROR, TermNil, "could not shmat at %p", MMAP_ADDR); - return(NULL); + if ((shm_id = shmget(IPC_PRIVATE, (size_t)s, SHM_R | SHM_W)) == -1) { + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "could not shmget %d bytes", s); + return (NULL); + } + if ((ptr = (MALLOC_T)shmat(shm_id, (void *)MMAP_ADDR, 0)) == (MALLOC_T)-1) { + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "could not shmat at %p", MMAP_ADDR); + return (NULL); } if (shmctl(shm_id, IPC_RMID, 0) != 0) { - Yap_Error(FATAL_ERROR, TermNil, "could not remove shm segment", shm_id); - return(NULL); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "could not remove shm segment", + shm_id); + return (NULL); } - WorkSpaceTop = (char *) ptr + s; - return(ptr); + WorkSpaceTop = (char *)ptr + s; + return (ptr); } -static int -ExtendWorkSpace(Int s) -{ +static int ExtendWorkSpace(Int s) { MALLOC_T ptr; int shm_id; prolog_exec_mode OldPrologMode = LOCAL_PrologMode; LOCAL_PrologMode = ExtendStackMode; /* mapping heap area */ - if((shm_id = shmget(IPC_PRIVATE, (size_t)s, SHM_R|SHM_W)) == -1) { + if ((shm_id = shmget(IPC_PRIVATE, (size_t)s, SHM_R | SHM_W)) == -1) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "could not shmget %d bytes", s); + "could not shmget %d bytes", s); LOCAL_PrologMode = OldPrologMode; - return(FALSE); - } - if((ptr = (MALLOC_T)shmat(shm_id, WorkSpaceTop, 0)) == (MALLOC_T) -1) { + return (FALSE); + } + if ((ptr = (MALLOC_T)shmat(shm_id, WorkSpaceTop, 0)) == (MALLOC_T)-1) { LOCAL_ErrorMessage = LOCAL_ErrorSay; - snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "could not shmat at %p", MMAP_ADDR); + snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, "could not shmat at %p", + MMAP_ADDR); LOCAL_PrologMode = OldPrologMode; - return(FALSE); + return (FALSE); } if (shmctl(shm_id, IPC_RMID, 0) != 0) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "could not remove shm segment", shm_id); + "could not remove shm segment", shm_id); LOCAL_PrologMode = OldPrologMode; - return(FALSE); + return (FALSE); } - WorkSpaceTop = (char *) ptr + s; + WorkSpaceTop = (char *)ptr + s; LOCAL_PrologMode = OldPrologMode; - return(TRUE); + return (TRUE); } -int -Yap_FreeWorkSpace(void) -{ - return TRUE; -} +int Yap_FreeWorkSpace(void) { return TRUE; } #elif USE_SBRK @@ -1284,74 +1206,63 @@ char *sbrk(int); #endif -int in_limbo; /* non-zero when restoring a saved state */ +int in_limbo; /* non-zero when restoring a saved state */ #ifndef LIMBO_SIZE -#define LIMBO_SIZE 32*K +#define LIMBO_SIZE 32 * K #endif -static char limbo_space[LIMBO_SIZE]; /* temporary malloc space */ +static char limbo_space[LIMBO_SIZE]; /* temporary malloc space */ static char *limbo_p = limbo_space, *limbo_pp = 0; -static MALLOC_T -InitWorkSpace(Int s) -{ +static MALLOC_T InitWorkSpace(Int s) { MALLOC_T ptr = (MALLOC_T)sbrk(s); - if (ptr == ((MALLOC_T) - 1)) { - Yap_Error(FATAL_ERROR, TermNil, "could not allocate %d bytes", s); - return(NULL); + if (ptr == ((MALLOC_T)-1)) { + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "could not allocate %d bytes", s); + return (NULL); } - return(ptr); + return (ptr); } -static int -ExtendWorkSpace(Int s) -{ +static int ExtendWorkSpace(Int s) { MALLOC_T ptr = (MALLOC_T)sbrk(s); prolog_exec_mode OldPrologMode = LOCAL_PrologMode; LOCAL_PrologMode = ExtendStackMode; - if (ptr == ((MALLOC_T) - 1)) { + if (ptr == ((MALLOC_T)-1)) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "could not expand stacks over %d bytes", s); + "could not expand stacks over %d bytes", s); LOCAL_PrologMode = OldPrologMode; - return(FALSE); + return (FALSE); } LOCAL_PrologMode = OldPrologMode; return TRUE; } -int -Yap_FreeWorkSpace(void) -{ - return TRUE; -} +int Yap_FreeWorkSpace(void) { return TRUE; } MALLOC_T -malloc(size_t size) -{ +malloc(size_t size) { if (in_limbo) { limbo_pp = limbo_p; limbo_p += (size + 7) & 0xffff8; if (limbo_p >= &limbo_space[LIMBO_SIZE]) - return(NULL); + return (NULL); return (limbo_pp); - } - else { - CODEADDR codep = (CODEADDR)AllocCodeSpace(size + 2*sizeof(void *)); + } else { + CODEADDR codep = (CODEADDR)AllocCodeSpace(size + 2 * sizeof(void *)); if (codep == NIL) - return(NIL); + return (NIL); else - return(codep + 2*sizeof(void *)); + return (codep + 2 * sizeof(void *)); } } -void -free(MALLOC_T ptr) -{ - BlockHeader *b = (BlockHeader *) (((char *) ptr) - 2*sizeof(void *) - sizeof(YAP_SEG_SIZE)); +void free(MALLOC_T ptr) { + BlockHeader *b = (BlockHeader *)(((char *)ptr) - 2 * sizeof(void *) - + sizeof(YAP_SEG_SIZE)); if (ptr == limbo_pp) { limbo_p = limbo_pp; @@ -1359,16 +1270,15 @@ free(MALLOC_T ptr) } if (!ptr) return; - if ((char *) ptr < Yap_HeapBase || (char *) ptr > HeapTop) + if ((char *)ptr < Yap_HeapBase || (char *)ptr > HeapTop) return; if (!(b->b_size & InUseFlag)) return; - FreeCodeSpace((char *) ptr - 2*sizeof(void *)); + FreeCodeSpace((char *)ptr - 2 * sizeof(void *)); } MALLOC_T -XX realloc(MALLOC_T ptr, size_t size) -{ +XX realloc(MALLOC_T ptr, size_t size) { MALLOC_T new = malloc(size); if (ptr) @@ -1378,8 +1288,7 @@ XX realloc(MALLOC_T ptr, size_t size) } MALLOC_T -calloc(size_t n, size_t e) -{ +calloc(size_t n, size_t e) { unsigned k = n * e; MALLOC_T p = malloc(k); @@ -1388,17 +1297,11 @@ calloc(size_t n, size_t e) } #ifdef M_MXFAST -int -mallopt(cmd, value) -{ - return (value); -} +int mallopt(cmd, value) { return (value); } static struct mallinfo xmall; -struct mallinfo -mallinfo(void) -{ +struct mallinfo mallinfo(void) { return (xmall); } #endif @@ -1410,59 +1313,56 @@ mallinfo(void) /* user should ask for a lot of memory first */ #ifdef __linux -#define MAX_SPACE 420*1024*1024 +#define MAX_SPACE 420 * 1024 * 1024 #else -#define MAX_SPACE 128*1024*1024 +#define MAX_SPACE 128 * 1024 * 1024 #endif static int total_space; -static MALLOC_T -InitWorkSpace(Int s) -{ +static MALLOC_T InitWorkSpace(Int s) { MALLOC_T ptr; #ifdef M_MMAP_MAX mallopt(M_MMAP_MAX, 0); #endif - ptr = (MALLOC_T)calloc(MAX_SPACE,1); + ptr = (MALLOC_T)calloc(MAX_SPACE, 1); total_space = s; if (ptr == NULL) { - Yap_Error(FATAL_ERROR, TermNil, "could not allocate %d bytes", s); - return(NULL); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "could not allocate %d bytes", s); + return (NULL); } - return(ptr); + return (ptr); } -static int -ExtendWorkSpace(Int s) -{ +static int ExtendWorkSpace(Int s) { MALLOC_T ptr; prolog_exec_mode OldPrologMode = LOCAL_PrologMode; LOCAL_PrologMode = ExtendStackMode; total_space += s; - if (total_space < MAX_SPACE) return TRUE; + if (total_space < MAX_SPACE) + return TRUE; ptr = (MALLOC_T)realloc((void *)Yap_HeapBase, total_space); if (ptr == NULL) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "could not allocate %d bytes", s); + "could not allocate %d bytes", s); LOCAL_PrologMode = OldPrologMode; return FALSE; } if (ptr != (MALLOC_T)Yap_HeapBase) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf4(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "could not expand contiguous stacks %d bytes", s); + "could not expand contiguous stacks %d bytes", s); LOCAL_PrologMode = OldPrologMode; return FALSE; } if ((CELL)ptr & MBIT) { LOCAL_ErrorMessage = LOCAL_ErrorSay; snprintf5(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, - "memory at %p conflicts with MBIT %lx", ptr, (unsigned long)MBIT); + "memory at %p conflicts with MBIT %lx", ptr, (unsigned long)MBIT); LOCAL_PrologMode = OldPrologMode; return FALSE; } @@ -1470,16 +1370,10 @@ ExtendWorkSpace(Int s) return TRUE; } -int -Yap_FreeWorkSpace(void) -{ - return TRUE; -} +int Yap_FreeWorkSpace(void) { return TRUE; } #endif -static void -InitHeap(void *heap_addr) -{ +static void InitHeap(void *heap_addr) { /* allocate space */ Yap_HeapBase = heap_addr; @@ -1490,47 +1384,40 @@ InitHeap(void *heap_addr) #if USE_DL_MALLOC Yap_initdlmalloc(); #else - HeapMax = HeapUsed = HeapTop-Yap_HeapBase; + HeapMax = HeapUsed = HeapTop - Yap_HeapBase; /* notice that this forces odd addresses */ - *((YAP_SEG_SIZE *) HeapTop) = InUseFlag; + *((YAP_SEG_SIZE *)HeapTop) = InUseFlag; HeapTop = HeapTop + sizeof(YAP_SEG_SIZE); - *((YAP_SEG_SIZE *) HeapTop) = InUseFlag; + *((YAP_SEG_SIZE *)HeapTop) = InUseFlag; #endif FreeBlocks = NIL; } -void -Yap_InitHeap(void *heap_addr) -{ - InitHeap(heap_addr); -} +void Yap_InitHeap(void *heap_addr) { InitHeap(heap_addr); } -void -Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) -{ +void Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) { UInt pm, sa, ta; void *addr; #if defined(_WIN32) || defined(__CYGWIN__) - Stack = ((Stack+ (YAP_ALLOC_SIZE-1))/YAP_ALLOC_SIZE)*YAP_ALLOC_SIZE; - Heap = ((Heap+ (YAP_ALLOC_SIZE-1))/YAP_ALLOC_SIZE)*YAP_ALLOC_SIZE; - Trail = ((Trail+ (YAP_ALLOC_SIZE-1))/YAP_ALLOC_SIZE)*YAP_ALLOC_SIZE; + Stack = ((Stack + (YAP_ALLOC_SIZE - 1)) / YAP_ALLOC_SIZE) * YAP_ALLOC_SIZE; + Heap = ((Heap + (YAP_ALLOC_SIZE - 1)) / YAP_ALLOC_SIZE) * YAP_ALLOC_SIZE; + Trail = ((Trail + (YAP_ALLOC_SIZE - 1)) / YAP_ALLOC_SIZE) * YAP_ALLOC_SIZE; #endif - pm = (Trail + Heap + Stack); /* memory to be - * requested */ - sa = Stack; /* stack area size */ - ta = Trail; /* trail area size */ - + pm = (Trail + Heap + Stack); /* memory to be + * requested */ + sa = Stack; /* stack area size */ + ta = Trail; /* trail area size */ #if RANDOMIZE_START_ADDRESS srand(time(NULL)); - UInt x = (rand()% 100)*YAP_ALLOC_SIZE ; + UInt x = (rand() % 100) * YAP_ALLOC_SIZE; pm += x; #endif addr = InitWorkSpace(pm); #if RANDOMIZE_START_ADDRESS - addr = (char *)addr+x; + addr = (char *)addr + x; pm -= x; #endif @@ -1541,33 +1428,34 @@ Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) LOCAL_TrailBase = LOCAL_LocalBase + sizeof(CELL); LOCAL_GlobalBase = LOCAL_LocalBase - sa; - HeapLim = LOCAL_GlobalBase; /* avoid confusions while - * * restoring */ + HeapLim = LOCAL_GlobalBase; /* avoid confusions while + * * restoring */ #if !USE_DL_MALLOC AuxTop = (ADDR)(AuxSp = (CELL *)LOCAL_GlobalBase); #endif #if DEBUG -#if SIZEOF_INT_P!=SIZEOF_INT +#if SIZEOF_INT_P != SIZEOF_INT if (Yap_output_msg) { - fprintf(stderr, "HeapBase = %p GlobalBase = %p\n LocalBase = %p TrailTop = %p\n", - Yap_HeapBase, LOCAL_GlobalBase, LOCAL_LocalBase, LOCAL_TrailTop); + fprintf(stderr, + "HeapBase = %p GlobalBase = %p\n LocalBase = %p TrailTop = %p\n", + Yap_HeapBase, LOCAL_GlobalBase, LOCAL_LocalBase, LOCAL_TrailTop); #else if (Yap_output_msg) { - fprintf(stderr, "HeapBase = %x GlobalBase = %x\n LocalBase = %x TrailTop = %x\n", - (UInt) Yap_HeapBase, (UInt) LOCAL_GlobalBase, - (UInt) LOCAL_LocalBase, (UInt) LOCAL_TrailTop); + fprintf(stderr, + "HeapBase = %x GlobalBase = %x\n LocalBase = %x TrailTop = %x\n", + (UInt)Yap_HeapBase, (UInt)LOCAL_GlobalBase, (UInt)LOCAL_LocalBase, + (UInt)LOCAL_TrailTop); #endif - fprintf(stderr, "Heap+Aux: " UInt_FORMAT "\tLocal+Global: " UInt_FORMAT "\tTrail: " UInt_FORMAT "\n", - pm - sa - ta, sa, ta); + fprintf(stderr, "Heap+Aux: " UInt_FORMAT "\tLocal+Global: " UInt_FORMAT + "\tTrail: " UInt_FORMAT "\n", + pm - sa - ta, sa, ta); } #endif /* DEBUG */ } -void -Yap_InitExStacks(int wid, int Trail, int Stack) -{ +void Yap_InitExStacks(int wid, int Trail, int Stack) { #if USE_DL_MALLOC REMOTE_ScratchPad(wid).ptr = NULL; REMOTE_ScratchPad(wid).sz = REMOTE_ScratchPad(wid).msz = SCRATCH_START_SIZE; @@ -1582,15 +1470,10 @@ Yap_InitExStacks(int wid, int Trail, int Stack) #if !USE_DL_MALLOC /* dead code */ -void Yap_add_memory_hole(ADDR Start, ADDR End) -{ - Yap_HoleSize += Start-End; -} +void Yap_add_memory_hole(ADDR Start, ADDR End) { Yap_HoleSize += Start - End; } #endif -int -Yap_ExtendWorkSpace(Int s) -{ +int Yap_ExtendWorkSpace(Int s) { #if USE_SYSTEM_MMAP return ExtendWorkSpace(s, MAP_FIXED); #elif defined(_WIN32) @@ -1600,19 +1483,17 @@ Yap_ExtendWorkSpace(Int s) #endif } -size_t -Yap_ExtendWorkSpaceThroughHole(size_t s) -{ +size_t Yap_ExtendWorkSpaceThroughHole(size_t s) { #if USE_SYSTEM_MMAP || defined(_WIN32) || defined(__CYGWIN__) MALLOC_T WorkSpaceTop0 = WorkSpaceTop; -#if SIZEOF_INT_P==4 +#if SIZEOF_INT_P == 4 while (WorkSpaceTop < (MALLOC_T)0xc0000000L) { /* progress 1 MB */ - WorkSpaceTop += 512*1024; + WorkSpaceTop += 512 * 1024; if (ExtendWorkSpace(s, MAP_FIXED)) { - Yap_add_memory_hole((ADDR)WorkSpaceTop0, (ADDR)WorkSpaceTop-s); + Yap_add_memory_hole((ADDR)WorkSpaceTop0, (ADDR)WorkSpaceTop - s); LOCAL_ErrorMessage = NULL; - return WorkSpaceTop-WorkSpaceTop0; + return WorkSpaceTop - WorkSpaceTop0; } #if defined(_WIN32) /* 487 happens when you step over someone else's memory */ @@ -1621,22 +1502,22 @@ Yap_ExtendWorkSpaceThroughHole(size_t s) return 0; } #endif -#elif SIZEOF_INT_P==8 +#elif SIZEOF_INT_P == 8 { - int n = 1024*1024; + int n = 1024 * 1024; while (n--) { /* progress 1 MB */ - WorkSpaceTop += 512*1024; + WorkSpaceTop += 512 * 1024; if (ExtendWorkSpace(s, MAP_FIXED)) { - Yap_add_memory_hole((ADDR)WorkSpaceTop0, (ADDR)WorkSpaceTop-s); - LOCAL_ErrorMessage = NULL; - return WorkSpaceTop-WorkSpaceTop0; + Yap_add_memory_hole((ADDR)WorkSpaceTop0, (ADDR)WorkSpaceTop - s); + LOCAL_ErrorMessage = NULL; + return WorkSpaceTop - WorkSpaceTop0; } #if defined(_WIN32) /* 487 happens when you step over someone else's memory */ if (GetLastError() != 487) { - WorkSpaceTop = WorkSpaceTop0; - return 0; + WorkSpaceTop = WorkSpaceTop0; + return 0; } #endif } @@ -1647,29 +1528,26 @@ Yap_ExtendWorkSpaceThroughHole(size_t s) return 0; } -void -Yap_AllocHole(UInt actual_request, UInt total_size) -{ -#if (USE_SYSTEM_MMAP || defined(_WIN32) || defined(__CYGWIN__)) && !USE_DL_MALLOC +void Yap_AllocHole(UInt actual_request, UInt total_size) { +#if (USE_SYSTEM_MMAP || defined(_WIN32) || defined(__CYGWIN__)) && \ + !USE_DL_MALLOC /* where we were when the hole was created, also where is the hole store */ - ADDR WorkSpaceTop0 = WorkSpaceTop-total_size; + ADDR WorkSpaceTop0 = WorkSpaceTop - total_size; BlockHeader *newb = (BlockHeader *)HeapTop; - BlockHeader *endb = (BlockHeader *)(WorkSpaceTop0-sizeof(YAP_SEG_SIZE)); - YAP_SEG_SIZE bsiz = (WorkSpaceTop0-HeapTop)/sizeof(CELL)-2*sizeof(YAP_SEG_SIZE)/sizeof(CELL); + BlockHeader *endb = (BlockHeader *)(WorkSpaceTop0 - sizeof(YAP_SEG_SIZE)); + YAP_SEG_SIZE bsiz = (WorkSpaceTop0 - HeapTop) / sizeof(CELL) - + 2 * sizeof(YAP_SEG_SIZE) / sizeof(CELL); /* push HeapTop to after hole */ - HeapTop = WorkSpaceTop-(actual_request-sizeof(YAP_SEG_SIZE)); - ((YAP_SEG_SIZE *) HeapTop)[0] = InUseFlag; + HeapTop = WorkSpaceTop - (actual_request - sizeof(YAP_SEG_SIZE)); + ((YAP_SEG_SIZE *)HeapTop)[0] = InUseFlag; /* now simulate a block */ - ((YAP_SEG_SIZE *) HeapTop)[-1] = - endb->b_size = - (HeapTop-WorkSpaceTop0)/sizeof(YAP_SEG_SIZE) | InUseFlag; + ((YAP_SEG_SIZE *)HeapTop)[-1] = endb->b_size = + (HeapTop - WorkSpaceTop0) / sizeof(YAP_SEG_SIZE) | InUseFlag; newb->b_size = bsiz; AddToFreeList(newb); #endif } #endif /* USE_SYSTEM_MALLOC */ - - diff --git a/C/amasm.c b/C/amasm.c index 6eb2b6fea..a91656637 100755 --- a/C/amasm.c +++ b/C/amasm.c @@ -143,7 +143,7 @@ * Handle overflows when allocating big clauses properly. * * Revision 1.66 2004/11/19 22:08:41 vsc -* replace SYSTEM_ERROR by out OUT_OF_WHATEVER_ERROR whenever appropriate. +* replace SYSTEM_ERROR_INTERNAL by out OUT_OF_WHATEVER_ERROR whenever appropriate. * * Revision 1.65 2004/10/26 20:15:48 vsc * More bug fixes for overflow handling @@ -1432,7 +1432,7 @@ a_p(op_numbers opcode, clause_info *clinfo, yamop *code_p, int pass_no, struct i break; default: op = _p_equal; /* just to make some compilers happy */ - Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "internal assembler error for built-in (%d)", (Flags & 0x7f)); + Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "internal assembler error for built-in (%d)", (Flags & 0x7f)); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); } @@ -1454,7 +1454,7 @@ a_p(op_numbers opcode, clause_info *clinfo, yamop *code_p, int pass_no, struct i if (cip->failure_handler && (Flags & TestPredFlag)) { if (pass_no) { if (Flags & UserCPredFlag) { - Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "user defined predicate cannot be a test predicate"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); @@ -1615,7 +1615,7 @@ compile_cmp_flags(unsigned char *s0) return GT_OK_IN_CMP|LT_OK_IN_CMP; if (strcmp(s,"\\==") == 0) return GT_OK_IN_CMP|LT_OK_IN_CMP; - Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "internal assembler error, %s/2 not recognised as binary op", s); + Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "internal assembler error, %s/2 not recognised as binary op", s); return 0; } @@ -2490,7 +2490,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci code_p->opc = opcode(_p_db_ref_y); break; case _cut_by: - Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "internal assembler error: cut_by should be handled as ->"); + Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "internal assembler error: cut_by should be handled as ->"); break; case _primitive: code_p->opc = opcode(_p_primitive_y); @@ -2532,7 +2532,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci code_p->opc = opcode(_p_db_ref_x); break; case _cut_by: - Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "internal assembler error: cut_by should be handled as ->"); + Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "internal assembler error: cut_by should be handled as ->"); break; case _primitive: code_p->opc = opcode(_p_primitive_x); @@ -2645,7 +2645,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci if (pass_no) { switch (opc) { case _plus: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for +/2 (should be XC)"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x1_arg, "internal assembler error CX for +/2 (should be XC)"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; @@ -2653,7 +2653,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci code_p->opc = emit_op(_p_minus_y_cv); break; case _times: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for */2 (should be XC)"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x1_arg, "internal assembler error CX for */2 (should be XC)"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; @@ -2661,12 +2661,12 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci code_p->opc = emit_op(_p_div_y_cv); break; case _and: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for /\\/2 (should be XC)"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x1_arg, "internal assembler error CX for /\\/2 (should be XC)"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; case _or: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for \\//2 (should be XC)"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x1_arg, "internal assembler error CX for \\//2 (should be XC)"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; @@ -2696,7 +2696,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci code_p->opc = emit_op(_p_plus_y_vc); break; case _minus: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error XC for -/2"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x2_arg, "internal assembler error XC for -/2"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; @@ -2729,7 +2729,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci } break; case _arg: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error for arg/3"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x2_arg, "internal assembler error for arg/3"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; @@ -2790,7 +2790,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci if (pass_no) { switch (opc) { case _plus: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for +/2"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x1_arg, "internal assembler error CX for +/2"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; @@ -2798,7 +2798,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci code_p->opc = emit_op(_p_minus_cv); break; case _times: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for */2"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x1_arg, "internal assembler error CX for */2"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; @@ -2806,12 +2806,12 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci code_p->opc = emit_op(_p_div_cv); break; case _and: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for /\\/2"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x1_arg, "internal assembler error CX for /\\/2"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; case _or: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for \\//2"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x1_arg, "internal assembler error CX for \\//2"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; @@ -2841,7 +2841,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci code_p->opc = emit_op(_p_plus_vc); break; case _minus: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error XC for -/2"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x2_arg, "internal assembler error XC for -/2"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; @@ -2874,7 +2874,7 @@ a_f2(cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermediates *ci } break; case _arg: - Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error for arg/3"); + Yap_Error(SYSTEM_ERROR_COMPILER, cmp_info->x2_arg, "internal assembler error for arg/3"); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); break; @@ -3527,7 +3527,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp if (pass_no) either_inst[either_cont++] = code_p; if (either_cont == MAX_DISJ_BRANCHES) { - Yap_Error(FATAL_ERROR,TermNil,"Too Many Branches in disjunction: please increase MAX_DISJ_BRANCHES in amasm.c\n"); + Yap_Error(SYSTEM_ERROR_FATAL,TermNil,"Too Many Branches in disjunction: please increase MAX_DISJ_BRANCHES in amasm.c\n"); exit(1); } code_p = a_either(_either, @@ -3723,7 +3723,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp break; #endif default: - Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "instruction %d found while assembling", (int) cip->cpc->op); + Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "instruction %d found while assembling", (int) cip->cpc->op); save_machine_regs(); siglongjmp(cip->CompilerBotch, 1); } @@ -3748,11 +3748,11 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep HR = h0; switch (LOCAL_Error_TYPE) { - case OUT_OF_STACK_ERROR: + case RESOURCE_ERROR_STACK: LOCAL_Error_Size = 256+((char *)cip->freep - (char *)HR); save_machine_regs(); siglongjmp(cip->CompilerBotch,3); - case OUT_OF_TRAIL_ERROR: + case RESOURCE_ERROR_TRAIL: /* don't just return NULL */ ARG1 = *tp; if (!Yap_growtrail(K64, FALSE)) { @@ -3761,7 +3761,7 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep LOCAL_Error_TYPE = YAP_NO_ERROR; *tp = ARG1; break; - case OUT_OF_AUXSPACE_ERROR: + case RESOURCE_ERROR_AUXILIARY_STACK: ARG1 = *tp; if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, (void *)cip, TRUE)) { return NULL; @@ -3769,7 +3769,7 @@ fetch_clause_space(Term* tp, UInt size, struct intermediates *cip, UInt *osizep LOCAL_Error_TYPE = YAP_NO_ERROR; *tp = ARG1; break; - case OUT_OF_HEAP_ERROR: + case RESOURCE_ERROR_HEAP: /* don't just return NULL */ ARG1 = *tp; if (!Yap_growheap(TRUE, size, cip)) { @@ -3899,7 +3899,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates while ((cip->code_addr = (yamop *) Yap_AllocCodeSpace(size)) == NULL) { if (!Yap_growheap(TRUE, size, cip)) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; LOCAL_Error_Size = size; return NULL; } diff --git a/C/arith0.c b/C/arith0.c index e93e6c238..fce74e9d3 100644 --- a/C/arith0.c +++ b/C/arith0.c @@ -266,7 +266,7 @@ Yap_InitConstExps(void) for (i = 0; i < sizeof(InitConstTab)/sizeof(InitConstEntry); ++i) { AtomEntry *ae = RepAtom(Yap_LookupAtom(InitConstTab[i].OpName)); if (ae == NULL) { - Yap_EvalError(OUT_OF_HEAP_ERROR,TermNil,"at InitConstExps"); + Yap_EvalError(RESOURCE_ERROR_HEAP,TermNil,"at InitConstExps"); return; } WRITE_LOCK(ae->ARWLock); diff --git a/C/arith1.c b/C/arith1.c index 7dd332ed0..cb0a9cba6 100644 --- a/C/arith1.c +++ b/C/arith1.c @@ -1050,7 +1050,7 @@ Yap_InitUnaryExps(void) for (i = 0; i < sizeof(InitUnTab)/sizeof(InitUnEntry); ++i) { AtomEntry *ae = RepAtom(Yap_LookupAtom(InitUnTab[i].OpName)); if (ae == NULL) { - Yap_EvalError(OUT_OF_HEAP_ERROR,TermNil,"at InitUnaryExps"); + Yap_EvalError(RESOURCE_ERROR_HEAP,TermNil,"at InitUnaryExps"); return; } WRITE_LOCK(ae->ARWLock); diff --git a/C/arith2.c b/C/arith2.c index 69506cd75..137bd421a 100644 --- a/C/arith2.c +++ b/C/arith2.c @@ -1342,7 +1342,7 @@ Yap_InitBinaryExps(void) for (i = 0; i < sizeof(InitBinTab)/sizeof(InitBinEntry); ++i) { AtomEntry *ae = RepAtom(Yap_LookupAtom(InitBinTab[i].OpName)); if (ae == NULL) { - Yap_EvalError(OUT_OF_HEAP_ERROR,TermNil,"at InitBinaryExps"); + Yap_EvalError(RESOURCE_ERROR_HEAP,TermNil,"at InitBinaryExps"); return; } WRITE_LOCK(ae->ARWLock); diff --git a/C/arrays.c b/C/arrays.c index 36bdeb845..9a91515f0 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -239,19 +239,19 @@ CloseMmappedArray(StaticArrayEntry *pp, void *area USES_REGS) } if (ptr == NULL) { #if !defined(USE_SYSTEM_MALLOC) - Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (array chain incoherent)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"close_mmapped_array (array chain incoherent)", strerror(errno)); #endif return FALSE; } if (munmap(ptr->start, ptr->size) == -1) { - Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (munmap: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"close_mmapped_array (munmap: %s)", strerror(errno)); return(FALSE); } optr->next = ptr->next; pp->ValueOfVE.ints = NULL; pp->ArrayEArity = 0; if (close(ptr->fd) < 0) { - Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (close: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"close_mmapped_array (close: %s)", strerror(errno)); return(FALSE); } Yap_FreeAtomSpace((char *)ptr); @@ -274,24 +274,24 @@ ResizeMmappedArray(StaticArrayEntry *pp, Int dim, void *area USES_REGS) and last we initialise again */ if (munmap(ptr->start, ptr->size) == -1) { - Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (munmap: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"resize_mmapped_array (munmap: %s)", strerror(errno)); return; } total_size = (ptr->size / ptr->items)*dim; if (ftruncate(ptr->fd, total_size) < 0) { - Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (ftruncate: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"resize_mmapped_array (ftruncate: %s)", strerror(errno)); return; } if (lseek(ptr->fd, total_size-1, SEEK_SET) < 0) { - Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (lseek: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"resize_mmapped_array (lseek: %s)", strerror(errno)); return; } if (write(ptr->fd, "", 1) < 0) { - Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (write: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"resize_mmapped_array (write: %s)", strerror(errno)); return; } if ((ptr->start = (void *)mmap(0, (size_t) total_size, PROT_READ | PROT_WRITE, MAP_SHARED, ptr->fd, 0)) == (void *) - 1) { - Yap_Error(SYSTEM_ERROR,ARG1,"resize_mmapped_array (mmap: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"resize_mmapped_array (mmap: %s)", strerror(errno)); return; } ptr->size = total_size; @@ -308,16 +308,16 @@ GetTermFromArray(DBTerm *ref USES_REGS) Term TRef; while ((TRef = Yap_FetchTermFromDB(ref)) == 0L) { - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, LOCAL_ErrorMessage); return TermNil; } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, Yap_gcP())) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return TermNil; } } @@ -703,7 +703,7 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, void *ol while ((p->ValueOfVE.floats = (Float *) Yap_AllocCodeSpace(asize) ) == NULL) { YAPLeaveCriticalSection(); if (!Yap_growheap(FALSE, asize, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return; } YAPEnterCriticalSection(); @@ -712,7 +712,7 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, void *ol while ((p->ValueOfVE.floats = (Float *) Yap_ReallocCodeSpace(old, asize) ) == NULL) { YAPLeaveCriticalSection(); if (!Yap_growheap(FALSE, asize, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return; } YAPEnterCriticalSection(); @@ -727,7 +727,7 @@ CreateStaticArray(AtomEntry *ae, size_t dim, static_array_types type, CODEADDR s if (EndOfPAEntr(p)) { while ((p = (StaticArrayEntry *) Yap_AllocCodeSpace(sizeof(*p))) == NULL) { if (!Yap_growheap(FALSE, sizeof(*p), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return NULL; } } @@ -998,12 +998,12 @@ p_create_array( USES_REGS1 ) farray = Yap_MkFunctor(AtomArray, size); if (HR+1+size > ASP-1024) { if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, Yap_gcP())) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK,TermNil,LOCAL_ErrorMessage); return(FALSE); } else { if (HR+1+size > ASP-1024) { if (!Yap_growstack( sizeof(CELL) * (size+1-(HR-ASP-1024)))) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return FALSE; } } @@ -1036,7 +1036,7 @@ p_create_array( USES_REGS1 ) if (HR+1+size > ASP-1024) { WRITE_UNLOCK(ae->ARWLock); if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK,TermNil,LOCAL_ErrorMessage); return(FALSE); } else goto restart; @@ -1057,7 +1057,7 @@ p_create_array( USES_REGS1 ) } else { if (HR+1+size > ASP-1024) { if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK,TermNil,LOCAL_ErrorMessage); return(FALSE); } else goto restart; @@ -1490,19 +1490,19 @@ p_create_mmapped_array( USES_REGS1 ) fd = open(filename, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR); if (fd == -1) { - Yap_Error(SYSTEM_ERROR,ARG1,"create_mmapped_array (open: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"create_mmapped_array (open: %s)", strerror(errno)); return(FALSE); } if (lseek(fd, total_size-1, SEEK_SET) < 0) - Yap_Error(SYSTEM_ERROR,tfile,"create_mmapped_array (lseek: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,tfile,"create_mmapped_array (lseek: %s)", strerror(errno)); if (write(fd, "", 1) < 0) - Yap_Error(SYSTEM_ERROR,tfile,"create_mmapped_array (write: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,tfile,"create_mmapped_array (write: %s)", strerror(errno)); /* if (ftruncate(fd, total_size) < 0) - Yap_Error(SYSTEM_ERROR,tfile,"create_mmapped_array"); + Yap_Error(SYSTEM_ERROR_INTERNAL,tfile,"create_mmapped_array"); */ if ((array_addr = (CODEADDR)mmap(0, (size_t) total_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == (CODEADDR) - 1) - Yap_Error(SYSTEM_ERROR,tfile,"create_mmapped_array (mmap: %s)", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL,tfile,"create_mmapped_array (mmap: %s)", strerror(errno)); } else { Yap_Error(TYPE_ERROR_ATOM,tfile,"create_mmapped_array"); return (FALSE); @@ -1552,7 +1552,7 @@ p_create_mmapped_array( USES_REGS1 ) return FALSE; } #else - Yap_Error(SYSTEM_ERROR,ARG1,"create_mmapped_array (mmap)"); + Yap_Error(SYSTEM_ERROR_INTERNAL,ARG1,"create_mmapped_array (mmap)"); return (FALSE); #endif } @@ -1777,7 +1777,7 @@ p_assign_static( USES_REGS1 ) MaBind(ptr, t3); return(TRUE); #else - Yap_Error(SYSTEM_ERROR,t2,"update_array"); + Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"update_array"); return(FALSE); #endif } else { @@ -1817,7 +1817,7 @@ p_assign_static( USES_REGS1 ) MaBind(pt, t3); return TRUE; #else - Yap_Error(SYSTEM_ERROR,t2,"update_array"); + Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"update_array"); return FALSE; #endif } @@ -2109,7 +2109,7 @@ p_assign_dynamic( USES_REGS1 ) MaBind(ptr, t3); return(TRUE); #else - Yap_Error(SYSTEM_ERROR,t2,"update_array"); + Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"update_array"); return(FALSE); #endif } else { @@ -2148,7 +2148,7 @@ p_assign_dynamic( USES_REGS1 ) MaBind(pt, t3); return TRUE; #else - Yap_Error(SYSTEM_ERROR,t2,"update_array"); + Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"update_array"); return FALSE; #endif } @@ -2195,7 +2195,7 @@ p_assign_dynamic( USES_REGS1 ) return TRUE; #else WRITE_UNLOCK(ptr->ArRWLock); - Yap_Error(SYSTEM_ERROR,t2,"update_array"); + Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"update_array"); return FALSE; #endif @@ -2301,7 +2301,7 @@ p_add_to_array_element( USES_REGS1 ) MaBind(ptr, ta); return(Yap_unify(ARG4,ta)); #else - Yap_Error(SYSTEM_ERROR,t2,"add_to_array_element"); + Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"add_to_array_element"); return(FALSE); #endif } else { @@ -2369,7 +2369,7 @@ p_add_to_array_element( USES_REGS1 ) WRITE_UNLOCK(pp->ArRWLock); return Yap_unify(ARG4,t3); #else - Yap_Error(SYSTEM_ERROR,t2,"add_to_array_element"); + Yap_Error(SYSTEM_ERROR_INTERNAL,t2,"add_to_array_element"); WRITE_UNLOCK(pp->ArRWLock); return FALSE; #endif @@ -2485,12 +2485,12 @@ p_static_array_to_term( USES_REGS1 ) while (HR+1+dim > ASP-1024) { if (!Yap_gcl((1+dim)*sizeof(CELL), 2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK,TermNil,LOCAL_ErrorMessage); return(FALSE); } else { if (HR+1+dim > ASP-1024) { if (!Yap_growstack( sizeof(CELL) * (dim+1-(HR-ASP-1024)))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } diff --git a/C/atomic.c b/C/atomic.c index 46ae11645..5fef91568 100644 --- a/C/atomic.c +++ b/C/atomic.c @@ -109,7 +109,7 @@ hide( USES_REGS1 ) } atomToInclude = AtomOfTerm(t1); if (AlreadyHidden(RepAtom(atomToInclude)->UStrOfAE)) { - Yap_Error(SYSTEM_ERROR,t1,"an atom of name %s was already hidden", + Yap_Error(SYSTEM_ERROR_INTERNAL,t1,"an atom of name %s was already hidden", RepAtom(atomToInclude)->StrOfAE); return(FALSE); } @@ -176,7 +176,7 @@ unhide( USES_REGS1 ) atom = RepAtom(AtomOfTerm(t1)); WRITE_LOCK(atom->ARWLock); if (atom->PropsOfAE != NIL) { - Yap_Error(SYSTEM_ERROR,t1,"cannot unhide an atom in use"); + Yap_Error(SYSTEM_ERROR_INTERNAL,t1,"cannot unhide an atom in use"); return(FALSE); } WRITE_LOCK(INVISIBLECHAIN.AERWLock); @@ -1019,7 +1019,7 @@ atom_concat2( USES_REGS1 ) Atom at; if (!inpv) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; free(inpv); goto error; } @@ -1067,7 +1067,7 @@ string_concat2( USES_REGS1 ) int i = 0; if (!inpv) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; free(inpv); goto error; } @@ -1116,7 +1116,7 @@ atomic_concat2( USES_REGS1 ) Atom at; if (!inpv) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; free(inpv); goto error; } @@ -1161,7 +1161,7 @@ atomics_to_string2( USES_REGS1 ) Atom at; if (!inpv) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; free(inpv); goto error; } @@ -1207,7 +1207,7 @@ atomics_to_string3( USES_REGS1 ) Atom at; if (!inpv) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; free(inpv); goto error; } @@ -1395,7 +1395,7 @@ atom_split( USES_REGS1 ) wlen = wcslen(ws); if (len > wlen) return FALSE; if (s1+len > (unsigned char *)LCL0-1024) - Yap_Error(OUT_OF_STACK_ERROR,t1,"$atom_split/4"); + Yap_Error(RESOURCE_ERROR_STACK,t1,"$atom_split/4"); for (i = 0; i< len; i++) { if (ws[i] > MAX_ISO_LATIN1) { break; @@ -1405,7 +1405,7 @@ atom_split( USES_REGS1 ) if (ws1[i] > MAX_ISO_LATIN1) { /* first sequence is wide */ if (ws1+len > (wchar_t *)ASP-1024) - Yap_Error(OUT_OF_STACK_ERROR,t1,"$atom_split/4"); + Yap_Error(RESOURCE_ERROR_STACK,t1,"$atom_split/4"); ws = (wchar_t *)RepAtom(at)->StrOfAE; for (i = 0; i< len; i++) { ws1[i] = ws[i]; @@ -1418,7 +1418,7 @@ atom_split( USES_REGS1 ) } else { char *s2 = (char *)HR; if (s2+(wlen-len) > (char *)ASP-1024) - Yap_Error(OUT_OF_STACK_ERROR,t1,"$atom_split/4"); + Yap_Error(RESOURCE_ERROR_STACK,t1,"$atom_split/4"); ws += len; while ((*s2++ = *ws++)); to2 = MkAtomTerm(Yap_LookupAtom(( char *)HR)); @@ -1435,7 +1435,7 @@ atom_split( USES_REGS1 ) s = RepAtom(at)->UStrOfAE; if (len > (Int)strlen((char *)s)) return(FALSE); if (s1+len > (unsigned char *)ASP-1024) - Yap_Error(OUT_OF_STACK_ERROR,t1,"$atom_split/4"); + Yap_Error(RESOURCE_ERROR_STACK,t1,"$atom_split/4"); for (i = 0; i< len; i++) { s1[i] = s[i]; } @@ -1510,7 +1510,7 @@ alloc_tmp_stack(size_t sz USES_REGS) { void *pt = (void *)HR; while (HR > ASP-(1044+sz/sizeof(CELL))) { if (!Yap_gc(5, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "sub_atom/5"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "sub_atom/5"); return(NULL); } } @@ -1548,7 +1548,7 @@ build_new_atomic(int mask, wchar_t *wp, const unsigned char *p, size_t min, size src = skip_utf8((unsigned char *)src, min); const unsigned char *cp = src; - LOCAL_TERM_ERROR( 4*(len+1) ); + LOCAL_TERM_ERROR( t, 4*(len+1) ); buf = buf_from_tstring(HR); while (len) { utf8proc_int32_t chr; diff --git a/C/attvar.c b/C/attvar.c index 1fad0cbac..294434a53 100644 --- a/C/attvar.c +++ b/C/attvar.c @@ -140,7 +140,7 @@ void Yap_MkEmptyWakeUp(Atom mod) { if (MaxEmptyWakeups == MAX_EMPTY_WAKEUPS) - Yap_Error(SYSTEM_ERROR, TermNil, "too many modules that do not wake up"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "too many modules that do not wake up"); EmptyWakeups[MaxEmptyWakeups++] = mod; } @@ -422,7 +422,7 @@ BindAttVar(attvar_record *attv USES_REGS) { Bind_Global_NonAtt(&(attv2->Done), AbsAttVar(attv)); } } else { - Yap_Error(SYSTEM_ERROR,(CELL)&(attv->Done),"attvar was bound when unset"); + Yap_Error(SYSTEM_ERROR_INTERNAL,(CELL)&(attv->Done),"attvar was bound when unset"); return(FALSE); } } else { @@ -431,7 +431,7 @@ BindAttVar(attvar_record *attv USES_REGS) { } return(TRUE); } else { - Yap_Error(SYSTEM_ERROR,(CELL)&(attv->Done),"attvar was bound when set"); + Yap_Error(SYSTEM_ERROR_INTERNAL,(CELL)&(attv->Done),"attvar was bound when set"); return(FALSE); } } @@ -467,7 +467,7 @@ p_put_att( USES_REGS1 ) { while (!(attv = BuildNewAttVar( PASS_REGS1 ))) { LOCAL_Error_Size = sizeof(attvar_record); if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } inp = Deref(ARG1); @@ -478,7 +478,7 @@ p_put_att( USES_REGS1 ) { if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) { while (!(tatts = BuildAttTerm(mfun,ar PASS_REGS))) { if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } @@ -512,7 +512,7 @@ p_put_att_term( USES_REGS1 ) { while (!(attv = BuildNewAttVar( PASS_REGS1 ))) { LOCAL_Error_Size = sizeof(attvar_record); if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } inp = Deref(ARG1); @@ -546,7 +546,7 @@ p_rm_att( USES_REGS1 ) { while (!(attv = BuildNewAttVar( PASS_REGS1 ))) { LOCAL_Error_Size = sizeof(attvar_record); if (!Yap_gcl(LOCAL_Error_Size, 5, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } inp = Deref(ARG1); @@ -558,7 +558,7 @@ p_rm_att( USES_REGS1 ) { if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) { while (!(tatts = BuildAttTerm(mfun, ar PASS_REGS))) { if (!Yap_gcl(LOCAL_Error_Size, 4, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } @@ -593,7 +593,7 @@ p_put_atts( USES_REGS1 ) { while (!(attv = BuildNewAttVar( PASS_REGS1 ))) { LOCAL_Error_Size = sizeof(attvar_record); if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } tatts = Deref(ARG2); @@ -992,7 +992,7 @@ p_all_attvars( USES_REGS1 ) if (!(out = AllAttVars( PASS_REGS1 ))) { if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } else { diff --git a/C/bb.c b/C/bb.c index f3285adc2..37ca03b72 100644 --- a/C/bb.c +++ b/C/bb.c @@ -60,7 +60,7 @@ PutBBProp(AtomEntry *ae, Term mod USES_REGS) /* get BBentry for at; */ p = (BBProp)Yap_AllocAtomSpace(sizeof(*p)); if (p == NULL) { WRITE_UNLOCK(ae->ARWLock); - Yap_Error(OUT_OF_HEAP_ERROR,ARG1,"could not allocate space in bb_put/2"); + Yap_Error(RESOURCE_ERROR_HEAP,ARG1,"could not allocate space in bb_put/2"); return(NULL); } AddPropToAtom(ae, (PropEntry *)p); @@ -91,7 +91,7 @@ PutIntBBProp(Int key, Term mod USES_REGS) /* get BBentry for at; */ pp++; } } else { - Yap_Error(OUT_OF_HEAP_ERROR,ARG1,"could not allocate space in bb_put/2"); + Yap_Error(RESOURCE_ERROR_HEAP,ARG1,"could not allocate space in bb_put/2"); return(NULL); } } @@ -108,7 +108,7 @@ PutIntBBProp(Int key, Term mod USES_REGS) /* get BBentry for at; */ p = (BBProp)Yap_AllocAtomSpace(sizeof(*p)); if (p == NULL) { YAPLeaveCriticalSection(); - Yap_Error(OUT_OF_HEAP_ERROR,ARG1,"could not allocate space in bb_put/2"); + Yap_Error(RESOURCE_ERROR_HEAP,ARG1,"could not allocate space in bb_put/2"); return(NULL); } p->ModuleOfBB = mod; @@ -179,7 +179,7 @@ resize_bb_int_keys(UInt new_size) { new = (Prop *)Yap_AllocCodeSpace(sizeof(Prop)*new_size); if (new == NULL) { YAPLeaveCriticalSection(); - Yap_Error(OUT_OF_HEAP_ERROR,ARG1,"could not allocate space"); + Yap_Error(RESOURCE_ERROR_HEAP,ARG1,"could not allocate space"); return(FALSE); } for (i = 0; i < new_size; i++) { diff --git a/C/bignum.c b/C/bignum.c index 4dc8146a7..390ab748b 100644 --- a/C/bignum.c +++ b/C/bignum.c @@ -170,14 +170,14 @@ int Yap_CleanOpaqueVariable(CELL *pt) #ifdef DEBUG /* sanity checking */ if (pt[0] != (CELL)FunctorBigInt) { - Yap_Error(SYSTEM_ERROR, TermNil, "CleanOpaqueVariable bad call"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "CleanOpaqueVariable bad call"); return FALSE; } #endif blob_tag = pt[1]; if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) { - Yap_Error(SYSTEM_ERROR, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag); + Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag); return FALSE; } blob_info = blob_tag - USER_BLOB_START; @@ -198,14 +198,14 @@ Yap_blob_write_handler(Term t) #ifdef DEBUG /* sanity checking */ if (pt[0] != (CELL)FunctorBigInt) { - Yap_Error(SYSTEM_ERROR, TermNil, "CleanOpaqueVariable bad call"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "CleanOpaqueVariable bad call"); return FALSE; } #endif blob_tag = pt[1]; if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) { - Yap_Error(SYSTEM_ERROR, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag); + Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag); return FALSE; } blob_info = blob_tag - USER_BLOB_START; @@ -224,7 +224,7 @@ Yap_blob_gc_mark_handler(Term t) #ifdef DEBUG /* sanity checking */ if (pt[0] != (CELL)FunctorBigInt) { - Yap_Error(SYSTEM_ERROR, TermNil, "CleanOpaqueVariable bad call"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "CleanOpaqueVariable bad call"); return FALSE; } #endif @@ -248,14 +248,14 @@ Yap_blob_gc_relocate_handler(Term t) #ifdef DEBUG /* sanity checking */ if (pt[0] != (CELL)FunctorBigInt) { - Yap_Error(SYSTEM_ERROR, TermNil, "CleanOpaqueVariable bad call"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "CleanOpaqueVariable bad call"); return FALSE; } #endif blob_tag = pt[1]; if (blob_tag < USER_BLOB_START || blob_tag >= USER_BLOB_END) { - Yap_Error(SYSTEM_ERROR, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag); + Yap_Error(SYSTEM_ERROR_INTERNAL, AbsAppl(pt), "clean opaque: bad blob with tag " UInt_FORMAT ,blob_tag); return FALSE; } blob_info = blob_tag - USER_BLOB_START; @@ -271,7 +271,7 @@ extern Int Yap_blob_tag(Term t) #ifdef DEBUG /* sanity checking */ if (pt[0] != (CELL)FunctorBigInt) { - Yap_Error(SYSTEM_ERROR, TermNil, "CleanOpaqueVariable bad call"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "CleanOpaqueVariable bad call"); return FALSE; } #endif @@ -287,7 +287,7 @@ Yap_blob_info(Term t) #ifdef DEBUG /* sanity checking */ if (pt[0] != (CELL)FunctorBigInt) { - Yap_Error(SYSTEM_ERROR, TermNil, "CleanOpaqueVariable bad call"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "CleanOpaqueVariable bad call"); return FALSE; } #endif @@ -342,7 +342,7 @@ Yap_HeapStoreOpaqueTerm(Term t) } new = Yap_AllocCodeSpace(sz); if (!new) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "subgoal_search_loop: no space for %s", StringOfTerm(t) ); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "subgoal_search_loop: no space for %s", StringOfTerm(t) ); } else { if (ptr[0] == (CELL)FunctorBigInt) { MP_INT *new = (MP_INT *)(RepAppl(t)+2); @@ -539,7 +539,7 @@ p_rational( USES_REGS1 ) (mpq_numref(rat)->_mp_alloc)*(sizeof(mp_limb_t)/CellSize) + (mpq_denref(rat)->_mp_alloc)*(sizeof(mp_limb_t)/CellSize); if (!Yap_gcl(size, 3, ENV, P)) { - Yap_Error(OUT_OF_STACK_ERROR, t, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, t, LOCAL_ErrorMessage); return FALSE; } } diff --git a/C/c_interface.c b/C/c_interface.c index d7413e671..4ab3ff8ab 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -256,7 +256,7 @@ * missing ; * * Revision 1.58 2004/11/19 22:08:41 vsc -* replace SYSTEM_ERROR by out OUT_OF_WHATEVER_ERROR whenever appropriate. +* replace SYSTEM_ERROR_INTERNAL by out OUT_OF_WHATEVER_ERROR whenever appropriate. * * Revision 1.57 2004/11/18 22:32:31 vsc * fix situation where we might assume nonextsing double initialisation of C predicates (use @@ -699,7 +699,7 @@ YAP_MkBlobTerm(unsigned int sz) while (HR+(sz+sizeof(MP_INT)/sizeof(CELL)+2) > ASP-1024) { if (!doexpand((sz+sizeof(MP_INT)/sizeof(CELL)+2)*sizeof(CELL))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "YAP failed to grow the stack while constructing a blob: %s", LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "YAP failed to grow the stack while constructing a blob: %s", LOCAL_ErrorMessage); return TermNil; } } @@ -796,7 +796,7 @@ YAP_LookupAtom(const char *c) a = Yap_LookupAtom(c); if (a == NIL || Yap_get_signal(YAP_CDOVF_SIGNAL)) { if (!Yap_locked_growheap(FALSE, 0, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); } } else { return a; @@ -815,7 +815,7 @@ YAP_LookupWideAtom(const wchar_t *c) a = Yap_LookupWideAtom((wchar_t *)c); if (a == NIL || Yap_get_signal(YAP_CDOVF_SIGNAL)) { if (!Yap_locked_growheap(FALSE, 0, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); } } else { return a; @@ -834,7 +834,7 @@ YAP_FullLookupAtom(const char *c) at = Yap_FullLookupAtom(c); if (at == NIL || Yap_get_signal(YAP_CDOVF_SIGNAL)) { if (!Yap_locked_growheap(FALSE, 0, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); } } else { return at; @@ -1354,7 +1354,7 @@ execute_cargs(PredEntry *pe, CPredicate exec_code USES_REGS) return code10(a1, a1+1, a1+2, a1+3, a1+4, a1+5, a1+6, a1+7, a1+8, a1+9); } default: - YAP_Error(SYSTEM_ERROR, TermNil, "YAP only supports SWI C-call with arity =< 10"); + YAP_Error(SYSTEM_ERROR_INTERNAL, TermNil, "YAP only supports SWI C-call with arity =< 10"); return(FALSE); } } @@ -1441,7 +1441,7 @@ execute_cargs_back(PredEntry *pe, CPredicate exec_code, struct foreign_context * return code10(a1, a1+1, a1+2, a1+3, a1+4, a1+5, a1+6, a1+7, a1+8, a1+9, ctx); } default: - YAP_Error(SYSTEM_ERROR, TermNil, "YAP only supports SWI C-call with arity =< 10"); + YAP_Error(SYSTEM_ERROR_INTERNAL, TermNil, "YAP only supports SWI C-call with arity =< 10"); return(FALSE); } } @@ -1755,7 +1755,7 @@ YAP_ReallocSpaceFromYap(void *ptr,size_t size) { BACKUP_MACHINE_REGS(); while ((new_ptr = Yap_ReallocCodeSpace(ptr,size)) == NULL) { if (!Yap_growheap(FALSE, size, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return NULL; } } @@ -1771,7 +1771,7 @@ YAP_AllocSpaceFromYap(size_t size) while ((ptr = Yap_AllocCodeSpace(size)) == NULL) { if (!Yap_growheap(FALSE, size, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return NULL; } } @@ -2136,7 +2136,7 @@ YAP_Error(int myerrno, Term t, const char *buf,...) char tmpbuf[YAP_BUF_SIZE]; if (!myerrno) - myerrno = SYSTEM_ERROR; + myerrno = SYSTEM_ERROR_INTERNAL; if (t == 0L) t = TermNil; if (buf != NULL) { @@ -2594,17 +2594,17 @@ YAP_GoalHasException(Term *t) if (LOCAL_Error_TYPE == YAP_NO_ERROR) { RECOVER_MACHINE_REGS(); return TRUE; - } else if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + } else if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, LOCAL_ErrorMessage); RECOVER_MACHINE_REGS(); return FALSE; } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growstack(EX->NOfCells*CellSize)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); RECOVER_MACHINE_REGS(); return FALSE; } @@ -2782,7 +2782,7 @@ YAP_CompileClause(Term t) if (Yap_get_signal( YAP_CDOVF_SIGNAL ) ) { if (!Yap_locked_growheap(FALSE, 0, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); } } RECOVER_MACHINE_REGS(); @@ -3012,7 +3012,7 @@ CACHE_REGS CurrentModule = USER_MODULE; P = GETWORK_FIRST_TIME; Yap_exec_absmi(FALSE, YAP_EXEC_ABSMI); - Yap_Error(INTERNAL_ERROR, TermNil, "abstract machine unexpected exit (YAP_Init)"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "abstract machine unexpected exit (YAP_Init)"); } #endif /* YAPOR */ RECOVER_MACHINE_REGS(); @@ -3709,7 +3709,7 @@ YAP_Record(Term t) if (!Yap_growheap(FALSE, sizeof(struct record_list), NULL)) { /* be a good neighbor */ Yap_FreeCodeSpace((void *)dbterm); - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "using YAP_Record"); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "using YAP_Record"); return NULL; } } @@ -3737,17 +3737,17 @@ YAP_Recorded(void *handle) if (LOCAL_Error_TYPE == YAP_NO_ERROR) { RECOVER_MACHINE_REGS(); return t; - } else if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + } else if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, LOCAL_ErrorMessage); RECOVER_MACHINE_REGS(); return FALSE; } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growstack(dbterm->NOfCells*CellSize)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); RECOVER_MACHINE_REGS(); return FALSE; } @@ -4044,7 +4044,7 @@ YAP_AtomToInt(Atom At) if (AtomTranslations == MaxAtomTranslations) { Atom * nt = (Atom *)malloc(sizeof(Atom)*2*MaxAtomTranslations), *ot = SWI_Atoms; if (nt == NULL) { - Yap_Error(SYSTEM_ERROR,MkAtomTerm(At),"No more room for translations"); + Yap_Error(SYSTEM_ERROR_INTERNAL,MkAtomTerm(At),"No more room for translations"); return -1; } memcpy(nt, ot, sizeof(Atom)*MaxAtomTranslations); @@ -4074,7 +4074,7 @@ YAP_FunctorToInt(Functor f) if (FunctorTranslations == MaxFunctorTranslations) { Functor * nt = (Functor *)malloc(sizeof(Functor)*2*MaxFunctorTranslations), *ot = SWI_Functors; if (nt == NULL) { - Yap_Error(SYSTEM_ERROR,MkAtomTerm(At),"No more room for translations"); + Yap_Error(SYSTEM_ERROR_INTERNAL,MkAtomTerm(At),"No more room for translations"); return -1; } memcpy(nt, ot, sizeof(Functor)*MaxFunctorTranslations); diff --git a/C/cdmgr.c b/C/cdmgr.c index 116052783..c14a3579c 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -519,7 +519,7 @@ InitConsultStack( void ) CACHE_REGS LOCAL_ConsultLow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity); if (LOCAL_ConsultLow == NULL) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitCodes"); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"No Heap Space in InitCodes"); return; } LOCAL_ConsultCapacity = InitialConsultCapacity; @@ -780,9 +780,9 @@ split_megaclause(PredEntry *ap) Yap_FreeCodeSpace((char *)cl); } if (ap->ArityOfPE) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while breaking up mega clause for %s/%d\n",RepAtom(NameOfFunctor(ap->FunctorOfPred))->StrOfAE,ap->ArityOfPE); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while breaking up mega clause for %s/%d\n",RepAtom(NameOfFunctor(ap->FunctorOfPred))->StrOfAE,ap->ArityOfPE); } else { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while breaking up mega clause for %s\n", RepAtom((Atom)ap->FunctorOfPred)->StrOfAE); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while breaking up mega clause for %s\n", RepAtom((Atom)ap->FunctorOfPred)->StrOfAE); } return; } @@ -862,7 +862,7 @@ IPred(PredEntry *ap, UInt NSlots, yamop *next_pc) #endif /* Do not try to index a dynamic predicate or one whithout args */ if (is_dynamic(ap)) { - Yap_Error(SYSTEM_ERROR,TermNil,"trying to index a dynamic predicate"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"trying to index a dynamic predicate"); return; } if ((BaseAddr = Yap_PredIsIndexable(ap, NSlots, next_pc)) != NULL) { @@ -1137,7 +1137,7 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code case _op_fail: return; default: - Yap_Error(SYSTEM_ERROR,TermNil,"Bug in Indexing Code: opcode %d", op); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"Bug in Indexing Code: opcode %d", op); return; } #if defined(YAPOR) || defined(THREADS) @@ -1588,7 +1588,7 @@ add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag) cl = (DynamicClause *) Yap_AllocCodeSpace((Int)NEXTOP(NEXTOP(NEXTOP(ncp,Otapl),e),l)); if (cl == NIL) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"Heap crashed against Stacks"); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"Heap crashed against Stacks"); return; } Yap_ClauseSpace += (Int)NEXTOP(NEXTOP(NEXTOP(ncp,Otapl),e),l); @@ -1834,7 +1834,7 @@ static void expand_consult( void ) /* I assume it always works ;-) */ while ((new_cl = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*LOCAL_ConsultCapacity)) == NULL) { if (!Yap_growheap(FALSE, sizeof(consult_obj)*LOCAL_ConsultCapacity, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,LOCAL_ErrorMessage); return; } } @@ -2245,7 +2245,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref) sc[3] = t; Yap_PrintWarning( Yap_MkApplTerm(Yap_MkFunctor(AtomStyleCheck, 4), 4, sc) ); } else if (Yap_multiple( p, mode PASS_REGS ) ) { - Term disc[4], sc[4], disct; + Term disc[4], sc[4]; if (p->ArityOfPE) { disc[0] = MkAtomTerm(NameOfFunctor(p->FunctorOfPred)); } else { @@ -2707,7 +2707,7 @@ p_purge_clauses( USES_REGS1 ) in case the objs pointing to it are dead themselves */ if (DeadMegaClauses != before) { if (!Yap_gc(2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } @@ -3959,18 +3959,18 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya ARG5 = th; ARG6 = tb; ARG7 = tr; - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { UNLOCK(pe->PELock); - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, LOCAL_ErrorMessage); return FALSE; } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_gcl(LOCAL_Error_Size, 7, ENV, gc_P(P,CP))) { UNLOCK(pe->PELock); - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } @@ -3983,7 +3983,7 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya ARG8 = tr; if (!Yap_gcl(LOCAL_Error_Size, 8, ENV, gc_P(P,CP))) { UNLOCK(pe->PELock); - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } th = ARG6; @@ -4107,18 +4107,18 @@ fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, Term tb, Term ARG5 = th; ARG6 = tb; ARG7 = tr; - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_locked_growglobal(NULL)) { UNLOCK(pe->PELock); - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, LOCAL_ErrorMessage); return FALSE; } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_locked_gcl(LOCAL_Error_Size, 7, ENV, gc_P(P,CP))) { UNLOCK(pe->PELock); - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } @@ -4131,7 +4131,7 @@ fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, Term tb, Term ARG8 = tr; if (!Yap_gcl(LOCAL_Error_Size, 8, ENV, CP)) { UNLOCK(pe->PELock); - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } th = ARG6; @@ -4215,7 +4215,7 @@ replace_integer(Term orig, UInt new) /* should create an old integer */ if (!IsApplTerm(orig)) { CACHE_REGS - Yap_Error(SYSTEM_ERROR,orig,"%uld-->%uld where it should increase",(unsigned long int)IntegerOfTerm(orig),(unsigned long int)new); + Yap_Error(SYSTEM_ERROR_INTERNAL,orig,"%uld-->%uld where it should increase",(unsigned long int)IntegerOfTerm(orig),(unsigned long int)new); return MkIntegerTerm(new); } /* appl->appl */ @@ -4376,7 +4376,7 @@ Yap_UpdateTimestamps(PredEntry *ap) LogUpdClause *lcl; #if THREADS - Yap_Error(SYSTEM_ERROR,TermNil,"Timestamp overflow %p", ap); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"Timestamp overflow %p", ap); return; #endif if (!ap->cs.p_code.NOfClauses) @@ -4484,7 +4484,7 @@ Yap_UpdateTimestamps(PredEntry *ap) return; overflow: if (!Yap_growstack(64*1024)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return; } goto restart; @@ -4585,10 +4585,10 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr } while ((t = Yap_FetchClauseTermFromDB(cl->usc.ClSource)) == 0L) { if (first_time) { - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, LOCAL_ErrorMessage); UNLOCKPE(45,pe); return FALSE; } @@ -4598,7 +4598,7 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr ARG6 = tb; ARG7 = tr; if (!Yap_gc(7, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); UNLOCKPE(45,pe); return FALSE; } @@ -4612,7 +4612,7 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr ARG7 = tb; ARG8 = tr; if (!Yap_gcl(LOCAL_Error_Size, 8, ENV, CP)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); UNLOCKPE(45,pe); return FALSE; } @@ -4899,7 +4899,7 @@ p_dbassert( USES_REGS1 ) /* instance(+Ref,?Term) */ static Int -p_instance_property( USES_REGS1 ) +instance_property( USES_REGS1 ) { Term t1 = Deref(ARG1); DBRef dbr; @@ -5293,7 +5293,7 @@ static Int predicate_flags(USES_REGS1) { /* $predicate_flags(+Functor,+Mod,?OldF if (IsAtomTerm(t1)) { while ((pe = RepPredProp(PredPropByAtom(AtomOfTerm(t1), mod))) == NULL) { if (!Yap_growheap(FALSE, 0, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, ARG1, "while generating new predicate"); + Yap_Error(RESOURCE_ERROR_HEAP, ARG1, "while generating new predicate"); return FALSE; } t1 = Deref(ARG1); @@ -5303,7 +5303,7 @@ static Int predicate_flags(USES_REGS1) { /* $predicate_flags(+Functor,+Mod,?OldF Functor funt = FunctorOfTerm(t1); while ((pe = RepPredProp(PredPropByFunc(funt, mod))) == NULL) { if (!Yap_growheap(FALSE, 0, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, ARG1, "while generating new predicate"); + Yap_Error(RESOURCE_ERROR_HEAP, ARG1, "while generating new predicate"); return FALSE; } t1 = Deref(ARG1); @@ -5404,7 +5404,7 @@ Yap_InitCdMgr(void) Yap_InitCPred("$static_clause", 4, p_static_clause, SyncPredFlag); Yap_InitCPred("$continue_static_clause", 5, p_continue_static_clause, SafePredFlag|SyncPredFlag); Yap_InitCPred("$static_pred_statistics", 5, p_static_pred_statistics, SyncPredFlag); - Yap_InitCPred("$instance_property", 3, p_instance_property, SafePredFlag|SyncPredFlag); + Yap_InitCPred("instance_property", 3, instance_property, SafePredFlag|SyncPredFlag); Yap_InitCPred("$fetch_nth_clause", 4, p_nth_instance, SyncPredFlag); CurrentModule = DBLOAD_MODULE; Yap_InitCPred("dbload_get_space", 4, p_dbload_get_space, 0L); diff --git a/C/compiler.c b/C/compiler.c index 90370ac22..2053d8349 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -137,7 +137,7 @@ * Handle overflows when allocating big clauses properly. * * Revision 1.54 2004/11/19 22:08:41 vsc -* replace SYSTEM_ERROR by out OUT_OF_WHATEVER_ERROR whenever appropriate. +* replace SYSTEM_ERROR_INTERNAL by out OUT_OF_WHATEVER_ERROR whenever appropriate. * * Revision 1.53 2004/09/03 03:11:08 vsc * memory management fixes @@ -579,7 +579,7 @@ compile_sf_term(Term t, int argno, int level) if (IsAtomicTerm(t)) Yap_emit((cglobs->onhead ? unify_s_a_op : write_s_a_op), t, (CELL) argno, &cglobs->cint); else if (!IsVarTerm(t)) { - LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_COMPILER; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "illegal argument of soft functor"; save_machine_regs(); @@ -607,7 +607,7 @@ c_args(Term app, unsigned int level, compiler_struct *cglobs) if (level == 0) { if (Arity >= MaxTemps) { - LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_COMPILER; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "exceed maximum arity of compiled goal"; save_machine_regs(); @@ -641,16 +641,16 @@ try_store_as_dbterm(Term t, Int argno, unsigned int arity, int level, compiler_s if ((dbt = Yap_StoreTermInDB(t, -1)) == NULL) { HR = h0; switch(LOCAL_Error_TYPE) { - case OUT_OF_STACK_ERROR: + case RESOURCE_ERROR_STACK: LOCAL_Error_TYPE = YAP_NO_ERROR; siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_STACK_BOTCH); - case OUT_OF_TRAIL_ERROR: + case RESOURCE_ERROR_TRAIL: LOCAL_Error_TYPE = YAP_NO_ERROR; siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_TRAIL_BOTCH); - case OUT_OF_HEAP_ERROR: + case RESOURCE_ERROR_HEAP: LOCAL_Error_TYPE = YAP_NO_ERROR; siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_HEAP_BOTCH); - case OUT_OF_AUXSPACE_ERROR: + case RESOURCE_ERROR_AUXILIARY_STACK: LOCAL_Error_TYPE = YAP_NO_ERROR; siglongjmp(cglobs->cint.CompilerBotch,OUT_OF_AUX_BOTCH); default: @@ -968,7 +968,7 @@ c_test(Int Op, Term t1, compiler_struct *cglobs) { if (!IsNewVar(t)) { char s[32]; - LOCAL_Error_TYPE = TYPE_ERROR_VARIABLE; + LOCAL_Error_TYPE = UNINSTANTIATION_ERROR; LOCAL_Error_Term = t; LOCAL_ErrorMessage = LOCAL_ErrorSay; Yap_bip_name(Op, s); @@ -1315,7 +1315,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler } else { char s[32]; - LOCAL_Error_TYPE = TYPE_ERROR_VARIABLE; + LOCAL_Error_TYPE = UNINSTANTIATION_ERROR; LOCAL_Error_Term = t1; LOCAL_ErrorMessage = LOCAL_ErrorSay; Yap_bip_name(Op, s); @@ -1338,7 +1338,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler } else { char s[32]; - LOCAL_Error_TYPE = TYPE_ERROR_VARIABLE; + LOCAL_Error_TYPE = UNINSTANTIATION_ERROR; LOCAL_Error_Term = t3; LOCAL_ErrorMessage = LOCAL_ErrorSay; Yap_bip_name(Op, s); @@ -2192,9 +2192,9 @@ c_head(Term t, compiler_struct *cglobs) #else { if (Yap_ExecutionMode == MIXED_MODE) - Yap_NilError(NOJIT_ERROR, "mixed"); + Yap_NilError(SYSTEM_ERROR_JIT_NOT_AVAILABLE, "mixed"); else /* Yap_ExecutionMode == COMPILED */ - Yap_NilError(NOJIT_ERROR, "just compiled"); + Yap_NilError(SYSTEM_ERROR_JIT_NOT_AVAILABLE, "just compiled"); } #endif c_args(t, 0, cglobs); @@ -2401,7 +2401,7 @@ clear_bvarray(int var, CELL *bvarray if (*bvarray & nbit) { CACHE_REGS /* someone had already marked this variable: complain */ - LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_COMPILER; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "compiler internal error: variable initialised twice"; save_machine_regs(); @@ -2443,7 +2443,7 @@ push_bvmap(int label, PInstr *pcpc, compiler_struct *cglobs) { if (bvindex == MAX_DISJUNCTIONS) { CACHE_REGS - LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_COMPILER; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "Too many embedded disjunctions"; save_machine_regs(); @@ -2467,7 +2467,7 @@ reset_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs) if (bvindex == 0) { CACHE_REGS - LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_COMPILER; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "No embedding in disjunctions"; save_machine_regs(); @@ -2488,7 +2488,7 @@ pop_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs) { if (bvindex == 0) { CACHE_REGS - LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_COMPILER; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "Too few embedded disjunctions"; /* save_machine_regs(); @@ -2542,7 +2542,7 @@ CheckUnsafe(PInstr *pc, compiler_struct *cglobs) if ( (v->FlagsOfVE & PermFlag && pc == v->FirstOpForV) || (v3->FlagsOfVE & PermFlag && pc == v3->FirstOpForV) ) { CACHE_REGS - LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_COMPILER; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "comparison should not have first instance of variables"; save_machine_regs(); @@ -2783,7 +2783,7 @@ checktemp(Int arg, Int rn, compiler_vm_op ic, compiler_struct *cglobs) } if (target1 == cglobs->MaxCTemps) { CACHE_REGS - LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_COMPILER; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "too many temporaries"; save_machine_regs(); @@ -2918,7 +2918,7 @@ c_layout(compiler_struct *cglobs) #ifdef DEBUG if (cglobs->pbvars != LOCAL_nperm) { CACHE_REGS - LOCAL_Error_TYPE = INTERNAL_COMPILER_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_COMPILER; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "wrong number of variables found in bitmap"; save_machine_regs(); @@ -3497,12 +3497,12 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src) YAPLeaveCriticalSection(); if (!Yap_gcl(LOCAL_Error_Size, NOfArgs, ENV, gc_P(P,CP))) { - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; LOCAL_Error_Term = inp_clause; } if (osize > ASP-HR) { if (!Yap_growstack(2*sizeof(CELL)*(ASP-HR))) { - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; LOCAL_Error_Term = inp_clause; } } @@ -3517,7 +3517,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src) ARG1 = inp_clause; ARG3 = src; if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) { - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; LOCAL_Error_Term = inp_clause; } YAPEnterCriticalSection(); @@ -3538,7 +3538,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src) ARG3 = src; YAPLeaveCriticalSection(); if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; LOCAL_Error_Term = inp_clause; return NULL; } @@ -3552,7 +3552,7 @@ Yap_cclause(volatile Term inp_clause, Int NOfArgs, Term mod, volatile Term src) ARG3 = src; YAPLeaveCriticalSection(); if (!Yap_growtrail(LOCAL_TrailTop-(ADDR)TR, FALSE)) { - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; LOCAL_Error_Term = inp_clause; return NULL; } diff --git a/C/corout.c b/C/corout.c index 70de6ebc4..79a9bfa61 100644 --- a/C/corout.c +++ b/C/corout.c @@ -462,7 +462,7 @@ non_ground(Term t, Term *Var USES_REGS) return out; } if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { - Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, "overflow in ground"); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, "overflow in ground"); return FALSE; } } diff --git a/C/cp_absmi_insts.h b/C/cp_absmi_insts.h index e1742c919..f564714eb 100644 --- a/C/cp_absmi_insts.h +++ b/C/cp_absmi_insts.h @@ -528,14 +528,14 @@ LOCAL_ReductionsCounter--; if (LOCAL_ReductionsCounter == 0 && LOCAL_ReductionsCounterOn) { saveregs(); - Yap_NilError(CALL_COUNTER_UNDERFLOW,""); + Yap_NilError(CALL_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -553,7 +553,7 @@ /* act as if we had backtracked */ ENV = B->cp_env; saveregs(); - Yap_NilError(RETRY_COUNTER_UNDERFLOW,""); + Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -561,7 +561,7 @@ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { ENV = B->cp_env; saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -590,14 +590,14 @@ LOCAL_RetriesCounter--; if (LOCAL_RetriesCounter == 0 && LOCAL_RetriesCounterOn) { saveregs(); - Yap_NilError(RETRY_COUNTER_UNDERFLOW,""); + Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -634,14 +634,14 @@ LOCAL_RetriesCounter--; if (LOCAL_RetriesCounter == 0) { saveregs(); - Yap_NilError(RETRY_COUNTER_UNDERFLOW,""); + Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -672,7 +672,7 @@ PREG = NEXTOP(PREG,Osbpa); saveregs(); if (!Yap_gcl(sz, arity, YENV, PREG)) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); FAIL(); } else { @@ -764,14 +764,14 @@ LOCAL_RetriesCounter--; if (LOCAL_RetriesCounter == 0) { saveregs(); - Yap_NilError(RETRY_COUNTER_UNDERFLOW,""); + Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } diff --git a/C/dbase.c b/C/dbase.c index c284738a4..d83017e13 100644 --- a/C/dbase.c +++ b/C/dbase.c @@ -15,29 +15,28 @@ * * *************************************************************************/ #ifdef SCCS -static char SccsId[] = "%W% %G%"; +static char SccsId[] = "%W% %G%"; #endif - /** @defgroup Internal_Database Internal Data Base @ingroup builtins @{ -Some programs need global information for, e.g. counting or collecting +Some programs need global information for, e.g. counting or collecting data obtained by backtracking. As a rule, to keep this information, the internal data base should be used instead of asserting and retracting clauses (as most novice programmers do), . -In YAP (as in some other Prolog systems) the internal data base (i.d.b. -for short) is faster, needs less space and provides a better insulation of +In YAP (as in some other Prolog systems) the internal data base (i.d.b. +for short) is faster, needs less space and provides a better insulation of program and data than using asserted/retracted clauses. -The i.d.b. is implemented as a set of terms, accessed by keys that -unlikely what happens in (non-Prolog) data bases are not part of the -term. Under each key a list of terms is kept. References are provided so that -terms can be identified: each term in the i.d.b. has a unique reference +The i.d.b. is implemented as a set of terms, accessed by keys that +unlikely what happens in (non-Prolog) data bases are not part of the +term. Under each key a list of terms is kept. References are provided so that +terms can be identified: each term in the i.d.b. has a unique reference (references are also available for clauses of dynamic predicates). -There is a strong analogy between the i.d.b. and the way dynamic -predicates are stored. In fact, the main i.d.b. predicates might be +There is a strong analogy between the i.d.b. and the way dynamic +predicates are stored. In fact, the main i.d.b. predicates might be implemented using dynamic predicates: ~~~~~ @@ -45,7 +44,7 @@ recorda(X,T,R) :- asserta(idb(X,T),R). recordz(X,T,R) :- assertz(idb(X,T),R). recorded(X,T,R) :- clause(idb(X,T),R). ~~~~~ -We can take advantage of this, the other way around, as it is quite +We can take advantage of this, the other way around, as it is quite easy to write a simple Prolog interpreter, using the i.d.b.: ~~~~~ @@ -56,10 +55,10 @@ call(V) :- var(V), !, fail. call((H :- B)) :- !, recorded(interpreter,(H :- B),_), call(B). call(G) :- recorded(interpreter,G,_). ~~~~~ -In YAP, much attention has been given to the implementation of the -i.d.b., especially to the problem of accelerating the access to terms kept in -a large list under the same key. Besides using the key, YAP uses an internal -lookup function, transparent to the user, to find only the terms that might +In YAP, much attention has been given to the implementation of the +i.d.b., especially to the problem of accelerating the access to terms kept in +a large list under the same key. Besides using the key, YAP uses an internal +lookup function, transparent to the user, to find only the terms that might unify. For instance, in a data base containing the terms ~~~~~ @@ -71,32 +70,32 @@ b(X) e(h) ~~~~~ -stored under the key k/1, when executing the query +stored under the key k/1, when executing the query ~~~~~ :- recorded(k(_),c(_),R). ~~~~~ -`recorded` would proceed directly to the third term, spending almost the +`recorded` would proceed directly to the third term, spending almost the time as if `a(X)` or `b(X)` was being searched. The lookup function uses the functor of the term, and its first three arguments (when they exist). So, `recorded(k(_),e(h),_)` would go directly to the last term, while `recorded(k(_),e(_),_)` would find first the fourth term, and then, after backtracking, the last one. -This mechanism may be useful to implement a sort of hierarchy, where -the functors of the terms (and eventually the first arguments) work as +This mechanism may be useful to implement a sort of hierarchy, where +the functors of the terms (and eventually the first arguments) work as secondary keys. -In the YAP's i.d.b. an optimized representation is used for -terms without free variables. This results in a faster retrieval of terms -and better space usage. Whenever possible, avoid variables in terms in terms stored in the i.d.b. +In the YAP's i.d.b. an optimized representation is used for +terms without free variables. This results in a faster retrieval of terms +and better space usage. Whenever possible, avoid variables in terms in terms +stored in the i.d.b. + - */ - #include "Yap.h" #include "clause.h" #include "yapio.h" @@ -116,7 +115,7 @@ and better space usage. Whenever possible, avoid variables in terms in terms sto it is physically disposed of. This simplifies things, because pointers are always valid, but it complicates some stuff a bit: - o You may have go through long lines of deleted db entries before you + o You may have go through long lines of deleted db entries before you actually reach the one you want. o Deleted clauses are also not removed of the chain. The solution @@ -126,7 +125,7 @@ and better space usage. Whenever possible, avoid variables in terms in terms sto An alternative solution is to remove clauses from the chain, even if they are still phisically present. Unfortunately this creates problems because immediate update semantics means you have to - backtrack clauses or see the db entries stored later. + backtrack clauses or see the db entries stored later. There are several solutions. One of the simplest is to use an age counter. When you backtrack to a removed clause or to a deleted db @@ -135,97 +134,95 @@ and better space usage. Whenever possible, avoid variables in terms in terms sto This still causes a problem when you backtrack to a deleted clause, because clauses are supposed to point to the next alternative, and having been removed from the chain you cannot - point there directly. One solution is to have a predicate in C that + point there directly. One solution is to have a predicate in C that recovers the place where to go to and then gets rid of the clause. */ - #define DISCONNECT_OLD_ENTRIES 1 #ifdef MACYAPBUG #define Register #else -#define Register register +#define Register register #endif /* Flags for recorda or recordz */ /* MkCode should be the same as CodeDBProperty */ -#define MkFirst 1 -#define MkCode CodeDBBit -#define MkLast 4 -#define WithRef 8 -#define MkIfNot 16 -#define InQueue 32 +#define MkFirst 1 +#define MkCode CodeDBBit +#define MkLast 4 +#define WithRef 8 +#define MkIfNot 16 +#define InQueue 32 -#define FrstDBRef(V) ( (V) -> First ) -#define NextDBRef(V) ( (V) -> Next ) +#define FrstDBRef(V) ((V)->First) +#define NextDBRef(V) ((V)->Next) -#define DBLength(V) (sizeof(DBStruct) + (Int)(V) + CellSize) -#define AllocDBSpace(V) ((DBRef)Yap_AllocCodeSpace(V)) -#define FreeDBSpace(V) Yap_FreeCodeSpace(V) +#define DBLength(V) (sizeof(DBStruct) + (Int)(V) + CellSize) +#define AllocDBSpace(V) ((DBRef)Yap_AllocCodeSpace(V)) +#define FreeDBSpace(V) Yap_FreeCodeSpace(V) -#if SIZEOF_INT_P==4 -#define ToSmall(V) ((link_entry)(Unsigned(V)>>2)) +#if SIZEOF_INT_P == 4 +#define ToSmall(V) ((link_entry)(Unsigned(V) >> 2)) #else -#define ToSmall(V) ((link_entry)(Unsigned(V)>>3)) +#define ToSmall(V) ((link_entry)(Unsigned(V) >> 3)) #endif #ifdef SFUNC -#define MaxSFs 256 +#define MaxSFs 256 typedef struct { - Term SName; /* The culprit */ - CELL *SFather; /* and his father's position */ -} SFKeep; + Term SName; /* The culprit */ + CELL *SFather; /* and his father's position */ +} SFKeep; #endif -#define HashFieldMask ((CELL)0xffL) -#define DualHashFieldMask ((CELL)0xffffL) -#define TripleHashFieldMask ((CELL)0xffffffL) -#define FourHashFieldMask ((CELL)0xffffffffL) +#define HashFieldMask ((CELL)0xffL) +#define DualHashFieldMask ((CELL)0xffffL) +#define TripleHashFieldMask ((CELL)0xffffffL) +#define FourHashFieldMask ((CELL)0xffffffffL) -#define ONE_FIELD_SHIFT 8 -#define TWO_FIELDS_SHIFT 16 -#define THREE_FIELDS_SHIFT 24 +#define ONE_FIELD_SHIFT 8 +#define TWO_FIELDS_SHIFT 16 +#define THREE_FIELDS_SHIFT 24 -#define AtomHash(t) (Unsigned(t)>>4) -#define FunctorHash(t) (Unsigned(t)>>4) -#define NumberHash(t) (Unsigned(IntOfTerm(t))) +#define AtomHash(t) (Unsigned(t) >> 4) +#define FunctorHash(t) (Unsigned(t) >> 4) +#define NumberHash(t) (Unsigned(IntOfTerm(t))) #define LARGE_IDB_LINK_TABLE 1 /* traditionally, YAP used a link table to recover IDB terms*/ #if LARGE_IDB_LINK_TABLE -typedef BITS32 link_entry; +typedef BITS32 link_entry; #define SIZEOF_LINK_ENTRY 4 #else -typedef BITS16 link_entry; +typedef BITS16 link_entry; #define SIZEOF_LINK_ENTRY 2 #endif /* These global variables are necessary to build the data base structure */ typedef struct db_globs { - link_entry *lr, *LinkAr; -/* we cannot call Error directly from within recorded(). These flags are used - to delay for a while -*/ - DBRef *tofref; /* place the refs also up */ + link_entry *lr, *LinkAr; + /* we cannot call Error directly from within recorded(). These flags are used + to delay for a while + */ + DBRef *tofref; /* place the refs also up */ #ifdef SFUNC - CELL *FathersPlace; /* Where the father was going when the term - * was reached */ - SFKeep *SFAr, *TopSF; /* Where are we putting our SFunctors */ + CELL *FathersPlace; /* Where the father was going when the term + * was reached */ + SFKeep *SFAr, *TopSF; /* Where are we putting our SFunctors */ #endif - DBRef found_one; /* Place where we started recording */ - UInt sz; /* total size */ + DBRef found_one; /* Place where we started recording */ + UInt sz; /* total size */ } dbglobs; - #ifdef SUPPORT_HASH_TABLES typedef struct { - CELL key; + CELL key; DBRef entry; } hash_db_entry; @@ -233,84 +230,87 @@ typedef table { Int NOfEntries; Int HashArg; hash_db_entry *table; -} hash_db_table; +} +hash_db_table; #endif -static CELL *cpcells(CELL *,CELL*,Int); -static void linkblk(link_entry *,CELL *,CELL); -static Int cmpclls(CELL *,CELL *,Int); +static CELL *cpcells(CELL *, CELL *, Int); +static void linkblk(link_entry *, CELL *, CELL); +static Int cmpclls(CELL *, CELL *, Int); static Prop FindDBProp(AtomEntry *, int, unsigned int, Term); -static CELL CalcKey(Term); +static CELL CalcKey(Term); #ifdef COROUTINING -static CELL *MkDBTerm(CELL *, CELL *, CELL *, CELL *, CELL *, CELL *,int *, struct db_globs *); +static CELL *MkDBTerm(CELL *, CELL *, CELL *, CELL *, CELL *, CELL *, int *, + struct db_globs *); #else -static CELL *MkDBTerm(CELL *, CELL *, CELL *, CELL *, CELL *, int *, struct db_globs *); +static CELL *MkDBTerm(CELL *, CELL *, CELL *, CELL *, CELL *, int *, + struct db_globs *); #endif -static DBRef CreateDBStruct(Term, DBProp, int, int *, UInt, struct db_globs *); -static DBRef record(int, Term, Term, Term CACHE_TYPE); -static DBRef check_if_cons(DBRef, Term); -static DBRef check_if_var(DBRef); -static DBRef check_if_wvars(DBRef, unsigned int, CELL *); -static int scheckcells(int, CELL *, CELL *, link_entry *, CELL); -static DBRef check_if_nvars(DBRef, unsigned int, CELL *, struct db_globs *); -static Int p_rcda( USES_REGS1 ); -static Int p_rcdap( USES_REGS1 ); -static Int p_rcdz( USES_REGS1 ); -static Int p_rcdzp( USES_REGS1 ); -static Int p_drcdap( USES_REGS1 ); -static Int p_drcdzp( USES_REGS1 ); -static Term GetDBTerm(DBTerm *, int src CACHE_TYPE); -static DBProp FetchDBPropFromKey(Term, int, int, char *); -static Int i_recorded(DBProp,Term CACHE_TYPE); -static Int c_recorded(int CACHE_TYPE); -static Int co_rded( USES_REGS1 ); -static Int in_rdedp( USES_REGS1 ); -static Int co_rdedp( USES_REGS1 ); -static Int p_first_instance( USES_REGS1 ); -static void ErasePendingRefs(DBTerm * CACHE_TYPE); -static void RemoveDBEntry(DBRef CACHE_TYPE); -static void EraseLogUpdCl(LogUpdClause *); -static void MyEraseClause(DynamicClause * CACHE_TYPE); -static void PrepareToEraseClause(DynamicClause *, DBRef); -static void EraseEntry(DBRef); -static Int p_erase( USES_REGS1 ); -static Int p_eraseall( USES_REGS1 ); -static Int p_erased( USES_REGS1 ); -static Int p_instance( USES_REGS1 ); -static int NotActiveDB(DBRef); -static DBEntry *NextDBProp(PropEntry *); -static Int init_current_key( USES_REGS1 ); -static Int cont_current_key( USES_REGS1 ); -static Int cont_current_key_integer( USES_REGS1 ); -static Int p_rcdstatp( USES_REGS1 ); -static Int p_somercdedp( USES_REGS1 ); -static yamop * find_next_clause(DBRef USES_REGS); -static Int p_jump_to_next_dynamic_clause( USES_REGS1 ); +static DBRef CreateDBStruct(Term, DBProp, int, int *, UInt, struct db_globs *); +static DBRef record(int, Term, Term, Term CACHE_TYPE); +static DBRef check_if_cons(DBRef, Term); +static DBRef check_if_var(DBRef); +static DBRef check_if_wvars(DBRef, unsigned int, CELL *); +static int scheckcells(int, CELL *, CELL *, link_entry *, CELL); +static DBRef check_if_nvars(DBRef, unsigned int, CELL *, struct db_globs *); +static Int p_rcda(USES_REGS1); +static Int p_rcdap(USES_REGS1); +static Int p_rcdz(USES_REGS1); +static Int p_rcdzp(USES_REGS1); +static Int p_drcdap(USES_REGS1); +static Int p_drcdzp(USES_REGS1); +static Term GetDBTerm(DBTerm *, int src CACHE_TYPE); +static DBProp FetchDBPropFromKey(Term, int, int, char *); +static Int i_recorded(DBProp, Term CACHE_TYPE); +static Int c_recorded(int CACHE_TYPE); +static Int co_rded(USES_REGS1); +static Int in_rdedp(USES_REGS1); +static Int co_rdedp(USES_REGS1); +static Int p_first_instance(USES_REGS1); +static void ErasePendingRefs(DBTerm *CACHE_TYPE); +static void RemoveDBEntry(DBRef CACHE_TYPE); +static void EraseLogUpdCl(LogUpdClause *); +static void MyEraseClause(DynamicClause *CACHE_TYPE); +static void PrepareToEraseClause(DynamicClause *, DBRef); +static void EraseEntry(DBRef); +static Int p_erase(USES_REGS1); +static Int p_eraseall(USES_REGS1); +static Int p_erased(USES_REGS1); +static Int p_instance(USES_REGS1); +static int NotActiveDB(DBRef); +static DBEntry *NextDBProp(PropEntry *); +static Int init_current_key(USES_REGS1); +static Int cont_current_key(USES_REGS1); +static Int cont_current_key_integer(USES_REGS1); +static Int p_rcdstatp(USES_REGS1); +static Int p_somercdedp(USES_REGS1); +static yamop *find_next_clause(DBRef USES_REGS); +static Int p_jump_to_next_dynamic_clause(USES_REGS1); #ifdef SFUNC -static void SFVarIn(Term); -static void sf_include(SFKeep *); +static void SFVarIn(Term); +static void sf_include(SFKeep *); #endif -static Int p_init_queue( USES_REGS1 ); -static Int p_enqueue( USES_REGS1 ); -static void keepdbrefs(DBTerm * CACHE_TYPE); -static Int p_dequeue( USES_REGS1 ); +static Int p_init_queue(USES_REGS1); +static Int p_enqueue(USES_REGS1); +static void keepdbrefs(DBTerm *CACHE_TYPE); +static Int p_dequeue(USES_REGS1); static void ErDBE(DBRef CACHE_TYPE); -static void ReleaseTermFromDB(DBTerm * CACHE_TYPE); +static void ReleaseTermFromDB(DBTerm *CACHE_TYPE); static PredEntry *new_lu_entry(Term); static PredEntry *new_lu_int_key(Int); static PredEntry *find_lu_entry(Term); static DBProp find_int_key(Int); -#define db_check_trail(x) { \ - if (Unsigned(dbg->tofref) == Unsigned(x)) { \ - goto error_tr_overflow; \ - } \ -} +#define db_check_trail(x) \ + { \ + if (Unsigned(dbg->tofref) == Unsigned(x)) { \ + goto error_tr_overflow; \ + } \ + } -static UInt new_trail_size(void) -{ +static UInt new_trail_size(void) { CACHE_REGS - UInt sz = (LOCAL_TrailTop-(ADDR)TR)/2; + UInt sz = (LOCAL_TrailTop - (ADDR)TR) / 2; if (sz < K64) return K64; if (sz > M1) @@ -318,32 +318,32 @@ static UInt new_trail_size(void) return sz; } -static int -recover_from_record_error(int nargs) -{ +static int recover_from_record_error(int nargs) { CACHE_REGS - switch(LOCAL_Error_TYPE) { - case OUT_OF_STACK_ERROR: - if (!Yap_gcl(LOCAL_Error_Size, nargs, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + switch (LOCAL_Error_TYPE) { + case RESOURCE_ERROR_STACK: + if (!Yap_gcl(LOCAL_Error_Size, nargs, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } goto recover_record; - case OUT_OF_TRAIL_ERROR: + case RESOURCE_ERROR_TRAIL: if (!Yap_growtrail(new_trail_size(), FALSE)) { - Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "YAP could not grow trail in recorda/3"); + Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, + "YAP could not grow trail in recorda/3"); return FALSE; } goto recover_record; - case OUT_OF_HEAP_ERROR: + case RESOURCE_ERROR_HEAP: if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, LOCAL_Error_Term, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, LOCAL_Error_Term, LOCAL_ErrorMessage); return FALSE; } goto recover_record; - case OUT_OF_AUXSPACE_ERROR: + case RESOURCE_ERROR_AUXILIARY_STACK: if (!Yap_ExpandPreAllocCodeSpace(LOCAL_Error_Size, NULL, TRUE)) { - Yap_Error(OUT_OF_AUXSPACE_ERROR, LOCAL_Error_Term, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, LOCAL_Error_Term, + LOCAL_ErrorMessage); return FALSE; } goto recover_record; @@ -351,17 +351,16 @@ recover_from_record_error(int nargs) Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage); return FALSE; } - recover_record: +recover_record: LOCAL_Error_Size = 0; LOCAL_Error_TYPE = YAP_NO_ERROR; return TRUE; } - #ifdef SUPPORT_HASH_TABLES /* related property and hint on number of entries */ static void create_hash_table(DBProp p, Int hint) { - int off = sizeof(CELL)*4, out; + int off = sizeof(CELL) * 4, out; Int size; if (hint < p->NOfEntries) @@ -377,39 +376,33 @@ static void create_hash_table(DBProp p, Int hint) { if ((size = ((CELL)1) << out) < hint) hint <<= 1; /* clean up the table */ - pt = tbl = (hash_db_entry *)AllocDBSpace(hint*sizeof(hash_db_entry)); - Yap_LUClauseSpace += hint*sizeof(hash_db_entry); - for (i=0; i< hint; i++) { + pt = tbl = (hash_db_entry *)AllocDBSpace(hint * sizeof(hash_db_entry)); + Yap_LUClauseSpace += hint * sizeof(hash_db_entry); + for (i = 0; i < hint; i++) { pt->key = NULL; pt++; } /* next insert the entries */ } -static void insert_in_table() { - -} +static void insert_in_table() {} -static void remove_from_table() { - -} +static void remove_from_table() {} #endif -inline static CELL *cpcells(CELL *to, CELL *from, Int n) -{ +inline static CELL *cpcells(CELL *to, CELL *from, Int n) { #if HAVE_MEMMOVE - memmove((void *)to, (void *)from, (size_t)(n*sizeof(CELL))); - return(to+n); + memmove((void *)to, (void *)from, (size_t)(n * sizeof(CELL))); + return (to + n); #else while (n-- >= 0) { *to++ = *from++; } - return(to); + return (to); #endif } -static void linkblk(link_entry *r, CELL *c, CELL offs) -{ +static void linkblk(link_entry *r, CELL *c, CELL offs) { CELL p; while ((p = (CELL)*r) != 0) { Term t = c[p]; @@ -418,170 +411,159 @@ static void linkblk(link_entry *r, CELL *c, CELL offs) } } -static Int cmpclls(CELL *a,CELL *b,Int n) -{ +static Int cmpclls(CELL *a, CELL *b, Int n) { while (n-- > 0) { - if(*a++ != *b++) return FALSE; + if (*a++ != *b++) + return FALSE; } return TRUE; } #if !THREADS -int Yap_DBTrailOverflow() -{ - return((CELL *)LOCAL_s_dbg->lr > (CELL *)LOCAL_s_dbg->tofref - 2048); +int Yap_DBTrailOverflow() { + return ((CELL *)LOCAL_s_dbg->lr > (CELL *)LOCAL_s_dbg->tofref - 2048); } #endif /* get DB entry for ap/arity; */ -static Prop -FindDBPropHavingLock(AtomEntry *ae, int CodeDB, unsigned int arity, Term dbmod) -{ - Prop p0; - DBProp p; +static Prop FindDBPropHavingLock(AtomEntry *ae, int CodeDB, unsigned int arity, + Term dbmod) { + Prop p0; + DBProp p; p = RepDBProp(p0 = ae->PropsOfAE); - while (p0 && (((p->KindOfPE & ~0x1) != (CodeDB|DBProperty)) || - (p->ArityOfDB != arity) || - ((CodeDB & MkCode) && p->ModuleOfDB && p->ModuleOfDB != dbmod))) { + while (p0 && + (((p->KindOfPE & ~0x1) != (CodeDB | DBProperty)) || + (p->ArityOfDB != arity) || + ((CodeDB & MkCode) && p->ModuleOfDB && p->ModuleOfDB != dbmod))) { p = RepDBProp(p0 = p->NextOfPE); } return p0; } - /* get DB entry for ap/arity; */ -static Prop -FindDBProp(AtomEntry *ae, int CodeDB, unsigned int arity, Term dbmod) -{ +static Prop FindDBProp(AtomEntry *ae, int CodeDB, unsigned int arity, + Term dbmod) { Prop out; READ_LOCK(ae->ARWLock); out = FindDBPropHavingLock(ae, CodeDB, arity, dbmod); READ_UNLOCK(ae->ARWLock); - return(out); + return (out); } - - /* These two functions allow us a fast lookup method in the data base */ /* PutMasks builds the mask and hash for a single argument */ -inline static CELL -CalcKey(Term tw) -{ +inline static CELL CalcKey(Term tw) { /* The first argument is known to be instantiated */ if (IsApplTerm(tw)) { Functor f = FunctorOfTerm(tw); if (IsExtensionFunctor(f)) { if (f == FunctorDBRef) { - return(FunctorHash(tw)); /* Ref */ + return (FunctorHash(tw)); /* Ref */ } /* if (f == FunctorLongInt || f == FunctorDouble) */ - return(NumberHash(RepAppl(tw)[1])); + return (NumberHash(RepAppl(tw)[1])); } - return(FunctorHash(f)); + return (FunctorHash(f)); } else if (IsAtomOrIntTerm(tw)) { if (IsAtomTerm(tw)) { - return(AtomHash(tw)); + return (AtomHash(tw)); } - return(NumberHash(tw)); + return (NumberHash(tw)); } - return(FunctorHash(FunctorList)); + return (FunctorHash(FunctorList)); } /* EvalMasks builds the mask and hash for up to three arguments of a term */ -static CELL -EvalMasks(register Term tm, CELL *keyp) -{ +static CELL EvalMasks(register Term tm, CELL *keyp) { if (IsVarTerm(tm)) { *keyp = 0L; - return(0L); + return (0L); } else if (IsApplTerm(tm)) { - Functor fun = FunctorOfTerm(tm); + Functor fun = FunctorOfTerm(tm); if (IsExtensionFunctor(fun)) { if (fun == FunctorDBRef) { - *keyp = FunctorHash(tm); /* Ref */ + *keyp = FunctorHash(tm); /* Ref */ } else /* if (f == FunctorLongInt || f == FunctorDouble) */ { - *keyp = NumberHash(RepAppl(tm)[1]); + *keyp = NumberHash(RepAppl(tm)[1]); } - return(FourHashFieldMask); + return (FourHashFieldMask); } else { - unsigned int arity; + unsigned int arity; arity = ArityOfFunctor(fun); #ifdef SFUNC - if (arity == SFArity) { /* do not even try to calculate masks */ - *keyp = key; - return(FourHashFieldMask); + if (arity == SFArity) { /* do not even try to calculate masks */ + *keyp = key; + return (FourHashFieldMask); } #endif switch (arity) { - case 1: - { - Term tw = ArgOfTerm(1, tm); + case 1: { + Term tw = ArgOfTerm(1, tm); - if (IsNonVarTerm(tw)) { - *keyp = (FunctorHash(fun) & DualHashFieldMask) | (CalcKey(tw) << TWO_FIELDS_SHIFT); - return(FourHashFieldMask); - } else { - *keyp = (FunctorHash(fun) & DualHashFieldMask); - return(DualHashFieldMask); - } - } - case 2: - { - Term tw1, tw2; - CELL key, mask; + if (IsNonVarTerm(tw)) { + *keyp = (FunctorHash(fun) & DualHashFieldMask) | + (CalcKey(tw) << TWO_FIELDS_SHIFT); + return (FourHashFieldMask); + } else { + *keyp = (FunctorHash(fun) & DualHashFieldMask); + return (DualHashFieldMask); + } + } + case 2: { + Term tw1, tw2; + CELL key, mask; - key = FunctorHash(fun) & DualHashFieldMask; - mask = DualHashFieldMask; + key = FunctorHash(fun) & DualHashFieldMask; + mask = DualHashFieldMask; - tw1 = ArgOfTerm(1, tm); - if (IsNonVarTerm(tw1)) { - key |= ((CalcKey(tw1) & HashFieldMask) << TWO_FIELDS_SHIFT); - mask |= (HashFieldMask << TWO_FIELDS_SHIFT); - } - tw2 = ArgOfTerm(2, tm); - if (IsNonVarTerm(tw2)) { - *keyp = key | (CalcKey(tw2) << THREE_FIELDS_SHIFT); - return(mask | (HashFieldMask << THREE_FIELDS_SHIFT)); - } else { - *keyp = key; - return(mask); - } - } - default: - { - Term tw1, tw2, tw3; - CELL key, mask; + tw1 = ArgOfTerm(1, tm); + if (IsNonVarTerm(tw1)) { + key |= ((CalcKey(tw1) & HashFieldMask) << TWO_FIELDS_SHIFT); + mask |= (HashFieldMask << TWO_FIELDS_SHIFT); + } + tw2 = ArgOfTerm(2, tm); + if (IsNonVarTerm(tw2)) { + *keyp = key | (CalcKey(tw2) << THREE_FIELDS_SHIFT); + return (mask | (HashFieldMask << THREE_FIELDS_SHIFT)); + } else { + *keyp = key; + return (mask); + } + } + default: { + Term tw1, tw2, tw3; + CELL key, mask; - key = FunctorHash(fun) & HashFieldMask; - mask = HashFieldMask; + key = FunctorHash(fun) & HashFieldMask; + mask = HashFieldMask; - tw1 = ArgOfTerm(1, tm); - if (IsNonVarTerm(tw1)) { - key |= (CalcKey(tw1) & HashFieldMask) << ONE_FIELD_SHIFT; - mask |= HashFieldMask << ONE_FIELD_SHIFT; - } - tw2 = ArgOfTerm(2, tm); - if (IsNonVarTerm(tw2)) { - key |= (CalcKey(tw2) & HashFieldMask) << TWO_FIELDS_SHIFT; - mask |= HashFieldMask << TWO_FIELDS_SHIFT; - } - tw3 = ArgOfTerm(3, tm); - if (IsNonVarTerm(tw3)) { - *keyp = key | (CalcKey(tw3) << THREE_FIELDS_SHIFT); - return(mask | (HashFieldMask << THREE_FIELDS_SHIFT)); - } else { - *keyp = key; - return(mask); - } - } + tw1 = ArgOfTerm(1, tm); + if (IsNonVarTerm(tw1)) { + key |= (CalcKey(tw1) & HashFieldMask) << ONE_FIELD_SHIFT; + mask |= HashFieldMask << ONE_FIELD_SHIFT; + } + tw2 = ArgOfTerm(2, tm); + if (IsNonVarTerm(tw2)) { + key |= (CalcKey(tw2) & HashFieldMask) << TWO_FIELDS_SHIFT; + mask |= HashFieldMask << TWO_FIELDS_SHIFT; + } + tw3 = ArgOfTerm(3, tm); + if (IsNonVarTerm(tw3)) { + *keyp = key | (CalcKey(tw3) << THREE_FIELDS_SHIFT); + return (mask | (HashFieldMask << THREE_FIELDS_SHIFT)); + } else { + *keyp = key; + return (mask); + } + } } } } else { - CELL key = (FunctorHash(FunctorList) & DualHashFieldMask); + CELL key = (FunctorHash(FunctorList) & DualHashFieldMask); CELL mask = DualHashFieldMask; Term th = HeadOfTerm(tm), tt; @@ -592,115 +574,97 @@ EvalMasks(register Term tm, CELL *keyp) tt = TailOfTerm(tm); if (IsNonVarTerm(tt)) { *keyp = key | (CalcKey(tt) << THREE_FIELDS_SHIFT); - return( mask|(HashFieldMask << THREE_FIELDS_SHIFT)); + return (mask | (HashFieldMask << THREE_FIELDS_SHIFT)); } *keyp = key; - return(mask); + return (mask); } } -CELL -Yap_EvalMasks(register Term tm, CELL *keyp) -{ - return EvalMasks(tm, keyp); -} - +CELL Yap_EvalMasks(register Term tm, CELL *keyp) { return EvalMasks(tm, keyp); } /* Called to inform that a new pointer to a data base entry has been added */ -#define MarkThisRef(Ref) ((Ref)->NOfRefsTo ++ ) +#define MarkThisRef(Ref) ((Ref)->NOfRefsTo++) /* From a term, builds its representation in the data base */ /* otherwise, we just need to restore variables*/ -typedef struct { - CELL *addr; -} visitel; -#define DB_UNWIND_CUNIF() \ - while (visited < (visitel *)AuxSp) { \ - RESET_VARIABLE(visited->addr); \ - visited ++; \ - } +typedef struct { CELL *addr; } visitel; +#define DB_UNWIND_CUNIF() \ + while (visited < (visitel *)AuxSp) { \ + RESET_VARIABLE(visited->addr); \ + visited++; \ + } /* no checking for overflow while building DB terms yet */ -#define CheckDBOverflow(X) if (CodeMax+X >= (CELL *)visited-1024) { \ - goto error; \ - } - +#define CheckDBOverflow(X) \ + if (CodeMax + X >= (CELL *)visited - 1024) { \ + goto error; \ + } + /* no checking for overflow while building DB terms yet */ -#define CheckVisitOverflow() if ((CELL *)to_visit+1024 >= ASP) { \ - goto error2; \ - } - -static CELL * -copy_long_int(CELL *st, CELL *pt) -{ +#define CheckVisitOverflow() \ + if ((CELL *)to_visit + 1024 >= ASP) { \ + goto error2; \ + } + +static CELL *copy_long_int(CELL *st, CELL *pt) { /* first thing, store a link to the list before we move on */ st[0] = (CELL)FunctorLongInt; st[1] = pt[1]; st[2] = EndSpecials; /* now reserve space */ - return st+3; + return st + 3; } -static CELL * -copy_double(CELL *st, CELL *pt) -{ +static CELL *copy_double(CELL *st, CELL *pt) { /* first thing, store a link to the list before we move on */ st[0] = (CELL)FunctorDouble; st[1] = pt[1]; -#if SIZEOF_DOUBLE == 2*SIZEOF_INT_P +#if SIZEOF_DOUBLE == 2 * SIZEOF_INT_P st[2] = pt[2]; st[3] = EndSpecials; #else st[2] = EndSpecials; #endif /* now reserve space */ - return st+(2+SIZEOF_DOUBLE/SIZEOF_INT_P); + return st + (2 + SIZEOF_DOUBLE / SIZEOF_INT_P); } -static CELL * -copy_string(CELL *st, CELL *pt) -{ - UInt sz = pt[1]+3; +static CELL *copy_string(CELL *st, CELL *pt) { + UInt sz = pt[1] + 3; /* first thing, store a link to the list before we move on */ - memcpy(st,pt,sizeof(CELL)*sz); + memcpy(st, pt, sizeof(CELL) * sz); /* now reserve space */ - return st+sz; + return st + sz; } #ifdef USE_GMP -static CELL * -copy_big_int(CELL *st, CELL *pt) -{ - Int sz = - sizeof(MP_INT)+ - (((MP_INT *)(pt+2))->_mp_alloc*sizeof(mp_limb_t)); +static CELL *copy_big_int(CELL *st, CELL *pt) { + Int sz = + sizeof(MP_INT) + (((MP_INT *)(pt + 2))->_mp_alloc * sizeof(mp_limb_t)); /* first functor */ st[0] = (CELL)FunctorBigInt; st[1] = pt[1]; /* then the actual number */ - memcpy((void *)(st+2), (void *)(pt+2), sz); - st = st+2+sz/CellSize; - /* then the tail for gc */ + memcpy((void *)(st + 2), (void *)(pt + 2), sz); + st = st + 2 + sz / CellSize; + /* then the tail for gc */ st[0] = EndSpecials; - return st+1; + return st + 1; } #endif /* BIG_INT */ #define DB_MARKED(d0) ((CELL *)(d0) < CodeMax && (CELL *)(d0) >= tbase) - /* This routine creates a complex term in the heap. */ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, - register CELL *StoPoint, - CELL *CodeMax, CELL *tbase, + register CELL *StoPoint, CELL *CodeMax, CELL *tbase, #ifdef COROUTINING - CELL *attachmentsp, + CELL *attachmentsp, #endif - int *vars_foundp, - struct db_globs *dbg) -{ + int *vars_foundp, struct db_globs *dbg) { CACHE_REGS #if THREADS #undef Yap_REGS @@ -719,100 +683,97 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, #endif CELL *CodeMaxBase = CodeMax; - loop: +loop: while (pt0 <= pt0_end) { CELL *ptd0 = pt0; CELL d0 = *ptd0; restart: if (IsVarTerm(d0)) - goto deref_var; + goto deref_var; if (IsApplTerm(d0)) { register Functor f; register CELL *ap2; - + /* we will need to link afterwards */ ap2 = RepAppl(d0); #ifdef RATIONAL_TREES if (ap2 >= tbase && ap2 <= StoPoint) { - db_check_trail(dbg->lr+1); - *dbg->lr++ = ToSmall((CELL)(StoPoint)-(CELL)(tbase)); - *StoPoint++ = d0; - ++pt0; - continue; + db_check_trail(dbg->lr + 1); + *dbg->lr++ = ToSmall((CELL)(StoPoint) - (CELL)(tbase)); + *StoPoint++ = d0; + ++pt0; + continue; } #endif - db_check_trail(dbg->lr+1); - *dbg->lr++ = ToSmall((CELL)(StoPoint)-(CELL)(tbase)); + db_check_trail(dbg->lr + 1); + *dbg->lr++ = ToSmall((CELL)(StoPoint) - (CELL)(tbase)); f = (Functor)(*ap2); if (IsExtensionFunctor(f)) { - switch((CELL)f) { - case (CELL)FunctorDBRef: - { - DBRef dbentry; - /* store now the correct entry */ - dbentry = DBRefOfTerm(d0); - *StoPoint++ = d0; - dbg->lr--; - if (dbentry->Flags & LogUpdMask) { - LogUpdClause *cl = (LogUpdClause *)dbentry; + switch ((CELL)f) { + case (CELL) FunctorDBRef: { + DBRef dbentry; + /* store now the correct entry */ + dbentry = DBRefOfTerm(d0); + *StoPoint++ = d0; + dbg->lr--; + if (dbentry->Flags & LogUpdMask) { + LogUpdClause *cl = (LogUpdClause *)dbentry; - cl->ClRefCount++; - } else { - dbentry->NOfRefsTo++; - } - *--dbg->tofref = dbentry; - db_check_trail(dbg->lr); - /* just continue the loop */ - ++ pt0; - continue; - } - case (CELL)FunctorLongInt: - CheckDBOverflow(3); - *StoPoint++ = AbsAppl(CodeMax); - CodeMax = copy_long_int(CodeMax, ap2); - ++pt0; - continue; + cl->ClRefCount++; + } else { + dbentry->NOfRefsTo++; + } + *--dbg->tofref = dbentry; + db_check_trail(dbg->lr); + /* just continue the loop */ + ++pt0; + continue; + } + case (CELL) FunctorLongInt: + CheckDBOverflow(3); + *StoPoint++ = AbsAppl(CodeMax); + CodeMax = copy_long_int(CodeMax, ap2); + ++pt0; + continue; #ifdef USE_GMP - case (CELL)FunctorBigInt: - CheckDBOverflow(3+Yap_SizeOfBigInt(d0)); - /* first thing, store a link to the list before we move on */ - *StoPoint++ = AbsAppl(CodeMax); - CodeMax = copy_big_int(CodeMax, ap2); - ++pt0; - continue; + case (CELL) FunctorBigInt: + CheckDBOverflow(3 + Yap_SizeOfBigInt(d0)); + /* first thing, store a link to the list before we move on */ + *StoPoint++ = AbsAppl(CodeMax); + CodeMax = copy_big_int(CodeMax, ap2); + ++pt0; + continue; #endif - case (CELL)FunctorString: - { - CELL *st = CodeMax; + case (CELL) FunctorString: { + CELL *st = CodeMax; - CheckDBOverflow(3+ap2[1]); - /* first thing, store a link to the list before we move on */ - *StoPoint++ = AbsAppl(st); - CodeMax = copy_string(CodeMax, ap2); - ++pt0; - continue; - } - case (CELL)FunctorDouble: - { - CELL *st = CodeMax; + CheckDBOverflow(3 + ap2[1]); + /* first thing, store a link to the list before we move on */ + *StoPoint++ = AbsAppl(st); + CodeMax = copy_string(CodeMax, ap2); + ++pt0; + continue; + } + case (CELL) FunctorDouble: { + CELL *st = CodeMax; - CheckDBOverflow(4); - /* first thing, store a link to the list before we move on */ - *StoPoint++ = AbsAppl(st); - CodeMax = copy_double(CodeMax, ap2); - ++pt0; - continue; - } - } + CheckDBOverflow(4); + /* first thing, store a link to the list before we move on */ + *StoPoint++ = AbsAppl(st); + CodeMax = copy_double(CodeMax, ap2); + ++pt0; + continue; + } + } } /* first thing, store a link to the list before we move on */ *StoPoint++ = AbsAppl(CodeMax); /* next, postpone analysis to the rest of the current list */ CheckVisitOverflow(); #ifdef RATIONAL_TREES - to_visit[0] = pt0+1; + to_visit[0] = pt0 + 1; to_visit[1] = pt0_end; to_visit[2] = StoPoint; to_visit[3] = (CELL *)*pt0; @@ -820,16 +781,16 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, *pt0 = StoPoint[-1]; #else if (pt0 < pt0_end) { - to_visit[0] = pt0+1; - to_visit[1] = pt0_end; - to_visit[2] = StoPoint; - to_visit += 3; + to_visit[0] = pt0 + 1; + to_visit[1] = pt0_end; + to_visit[2] = StoPoint; + to_visit += 3; } #endif d0 = ArityOfFunctor(f); - pt0 = ap2+1; + pt0 = ap2 + 1; pt0_end = ap2 + d0; - CheckDBOverflow(d0+1); + CheckDBOverflow(d0 + 1); /* prepare for our new compound term */ /* first the functor */ *CodeMax++ = (CELL)f; @@ -838,74 +799,71 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, /* now reserve space */ CodeMax += d0; continue; - } - else if (IsPairTerm(d0)) { + } else if (IsPairTerm(d0)) { /* we will need to link afterwards */ CELL *ap2 = RepPair(d0); if (ap2 >= tbase && ap2 <= StoPoint) { - db_check_trail(dbg->lr+1); - *dbg->lr++ = ToSmall((CELL)(StoPoint)-(CELL)(tbase)); - *StoPoint++ = d0; - ++pt0; - continue; + db_check_trail(dbg->lr + 1); + *dbg->lr++ = ToSmall((CELL)(StoPoint) - (CELL)(tbase)); + *StoPoint++ = d0; + ++pt0; + continue; } - if (IsAtomOrIntTerm(Deref(ap2[0])) && - IsPairTerm(Deref(ap2[1]))) { - /* shortcut for [1,2,3,4,5] */ - Term tt = Deref(ap2[1]); - Term th = Deref(ap2[0]); - Int direction = RepPair(tt)-ap2; - CELL *OldStoPoint; - CELL *lp; + if (IsAtomOrIntTerm(Deref(ap2[0])) && IsPairTerm(Deref(ap2[1]))) { + /* shortcut for [1,2,3,4,5] */ + Term tt = Deref(ap2[1]); + Term th = Deref(ap2[0]); + Int direction = RepPair(tt) - ap2; + CELL *OldStoPoint; + CELL *lp; - if (direction < 0) - direction = -1; - else - direction = 1; - db_check_trail(dbg->lr+1); - *dbg->lr++ = ToSmall((CELL)(StoPoint)-(CELL)(tbase)); - *StoPoint++ = AbsPair(CodeMax); - OldStoPoint = StoPoint; - do { - lp = RepPair(tt); - - if (lp >= tbase && lp <= StoPoint) { - break; - } - CheckDBOverflow(2); - CodeMax[0] = th; - db_check_trail(dbg->lr+1); - *dbg->lr++ = ToSmall((CELL)(CodeMax+1)-(CELL)(tbase)); - CodeMax[1] = AbsPair(CodeMax+2); - CodeMax+=2; - th = Deref(lp[0]); - tt = Deref(lp[1]); - } while (IsAtomOrIntTerm(th) && - IsPairTerm(tt) && - /* have same direction to avoid infinite terms X = [a|X] */ - (RepPair(tt)-lp)*direction > 0); - if (lp >= tbase && lp <= StoPoint) { - CodeMax[-1] = tt; - break; - } - if (IsAtomOrIntTerm(th) && IsAtomOrIntTerm(tt)) { - CheckDBOverflow(2); - CodeMax[0] = th; - CodeMax[1] = tt; - CodeMax+=2; - ++pt0; - continue; - } - d0 = AbsPair(lp); - StoPoint = OldStoPoint; + if (direction < 0) + direction = -1; + else + direction = 1; + db_check_trail(dbg->lr + 1); + *dbg->lr++ = ToSmall((CELL)(StoPoint) - (CELL)(tbase)); + *StoPoint++ = AbsPair(CodeMax); + OldStoPoint = StoPoint; + do { + lp = RepPair(tt); + + if (lp >= tbase && lp <= StoPoint) { + break; + } + CheckDBOverflow(2); + CodeMax[0] = th; + db_check_trail(dbg->lr + 1); + *dbg->lr++ = ToSmall((CELL)(CodeMax + 1) - (CELL)(tbase)); + CodeMax[1] = AbsPair(CodeMax + 2); + CodeMax += 2; + th = Deref(lp[0]); + tt = Deref(lp[1]); + } while (IsAtomOrIntTerm(th) && IsPairTerm(tt) && + /* have same direction to avoid infinite terms X = [a|X] */ + (RepPair(tt) - lp) * direction > 0); + if (lp >= tbase && lp <= StoPoint) { + CodeMax[-1] = tt; + break; + } + if (IsAtomOrIntTerm(th) && IsAtomOrIntTerm(tt)) { + CheckDBOverflow(2); + CodeMax[0] = th; + CodeMax[1] = tt; + CodeMax += 2; + ++pt0; + continue; + } + d0 = AbsPair(lp); + StoPoint = OldStoPoint; } else { - db_check_trail(dbg->lr+1); - *dbg->lr++ = ToSmall((CELL)(StoPoint)-(CELL)(tbase)); - *StoPoint++ = AbsPair(CodeMax); + db_check_trail(dbg->lr + 1); + *dbg->lr++ = ToSmall((CELL)(StoPoint) - (CELL)(tbase)); + *StoPoint++ = AbsPair(CodeMax); } - /* next, postpone analysis to the rest of the current list */ +/* next, postpone analysis to the rest of the current list */ #ifdef RATIONAL_TREES - to_visit[0] = pt0+1; + to_visit[0] = pt0 + 1; to_visit[1] = pt0_end; to_visit[2] = StoPoint; to_visit[3] = (CELL *)*pt0; @@ -913,10 +871,10 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, *pt0 = StoPoint[-1]; #else if (pt0 < pt0_end) { - to_visit[0] = pt0+1; - to_visit[1] = pt0_end; - to_visit[2] = StoPoint; - to_visit += 3; + to_visit[0] = pt0 + 1; + to_visit[1] = pt0_end; + to_visit[2] = StoPoint; + to_visit += 3; } #endif CheckVisitOverflow(); @@ -935,84 +893,82 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, ++pt0; continue; } - - /* the code to dereference a variable */ + + /* the code to dereference a variable */ deref_var: if (!DB_MARKED(d0)) { - if ( + if ( #if YAPOR_SBA - d0 != 0 + d0 != 0 #else - d0 != (CELL)ptd0 + d0 != (CELL)ptd0 #endif - ) { - ptd0 = (Term *) d0; - d0 = *ptd0; - goto restart; /* continue dereferencing */ + ) { + ptd0 = (Term *)d0; + d0 = *ptd0; + goto restart; /* continue dereferencing */ } /* else just drop to found_var */ } /* else just drop to found_var */ { - CELL displacement = (CELL)(StoPoint)-(CELL)(tbase); - + CELL displacement = (CELL)(StoPoint) - (CELL)(tbase); + pt0++; /* first time we found this variable! */ if (!DB_MARKED(d0)) { - - /* store previous value */ - visited --; - visited->addr = ptd0; - CheckDBOverflow(1); - /* variables need to be offset at read time */ - *ptd0 = (CELL)StoPoint; + + /* store previous value */ + visited--; + visited->addr = ptd0; + CheckDBOverflow(1); + /* variables need to be offset at read time */ + *ptd0 = (CELL)StoPoint; #if YAPOR_SBA - /* the copy we keep will be an empty variable */ - *StoPoint++ = 0; + /* the copy we keep will be an empty variable */ + *StoPoint++ = 0; #else - /* the copy we keep will be the current displacement */ - *StoPoint = (CELL)StoPoint; - StoPoint++; - db_check_trail(dbg->lr+1); - *dbg->lr++ = ToSmall(displacement); + /* the copy we keep will be the current displacement */ + *StoPoint = (CELL)StoPoint; + StoPoint++; + db_check_trail(dbg->lr + 1); + *dbg->lr++ = ToSmall(displacement); #endif - /* indicate we found variables */ - vars_found++; + /* indicate we found variables */ + vars_found++; #ifdef COROUTINING - if (SafeIsAttachedTerm((CELL)ptd0)) { - Term t[4]; - int sz = to_visit-to_visit_base; + if (SafeIsAttachedTerm((CELL)ptd0)) { + Term t[4]; + int sz = to_visit - to_visit_base; - HR = (CELL *)to_visit; - /* store the constraint away for: we need a back pointer to - the variable, the constraint in some cannonical form, what type - of constraint, and a list pointer */ - t[0] = (CELL)ptd0; - t[1] = GLOBAL_attas[ExtFromCell(ptd0)].to_term_op(ptd0); - t[2] = MkIntegerTerm(ExtFromCell(ptd0)); - t[3] = ConstraintsTerm; - ConstraintsTerm = Yap_MkApplTerm(FunctorClist, 4, t); - if (HR+sz >= ASP) { - goto error2; - } - memcpy((void *)HR, (void *)(to_visit_base), sz*sizeof(CELL *)); - to_visit_base = (CELL **)HR; - to_visit = to_visit_base+sz; - } + HR = (CELL *)to_visit; + /* store the constraint away for: we need a back pointer to + the variable, the constraint in some cannonical form, what type + of constraint, and a list pointer */ + t[0] = (CELL)ptd0; + t[1] = GLOBAL_attas[ExtFromCell(ptd0)].to_term_op(ptd0); + t[2] = MkIntegerTerm(ExtFromCell(ptd0)); + t[3] = ConstraintsTerm; + ConstraintsTerm = Yap_MkApplTerm(FunctorClist, 4, t); + if (HR + sz >= ASP) { + goto error2; + } + memcpy((void *)HR, (void *)(to_visit_base), sz * sizeof(CELL *)); + to_visit_base = (CELL **)HR; + to_visit = to_visit_base + sz; + } #endif - continue; - } else { - /* references need to be offset at read time */ - db_check_trail(dbg->lr+1); - *dbg->lr++ = ToSmall(displacement); - /* store the offset */ - *StoPoint = d0; - StoPoint++; - continue; + continue; + } else { + /* references need to be offset at read time */ + db_check_trail(dbg->lr + 1); + *dbg->lr++ = ToSmall(displacement); + /* store the offset */ + *StoPoint = d0; + StoPoint++; + continue; } - } - } /* Do we still have compound terms to visit */ @@ -1036,10 +992,10 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, #ifdef COROUTINING /* we still may have constraints to do */ if (ConstraintsTerm != TermNil && - !IN_BETWEEN(tbase,RepAppl(ConstraintsTerm),CodeMax)) { - *attachmentsp = (CELL)(CodeMax+1); - pt0 = RepAppl(ConstraintsTerm)+1; - pt0_end = RepAppl(ConstraintsTerm)+4; + !IN_BETWEEN(tbase, RepAppl(ConstraintsTerm), CodeMax)) { + *attachmentsp = (CELL)(CodeMax + 1); + pt0 = RepAppl(ConstraintsTerm) + 1; + pt0_end = RepAppl(ConstraintsTerm) + 4; StoPoint = CodeMax; *StoPoint++ = RepAppl(ConstraintsTerm)[0]; ConstraintsTerm = AbsAppl(CodeMax); @@ -1056,9 +1012,9 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, #endif return CodeMax; - error: - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; - LOCAL_Error_Size = 1024+((char *)AuxSp-(char *)CodeMaxBase); +error: + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; + LOCAL_Error_Size = 1024 + ((char *)AuxSp - (char *)CodeMaxBase); *vars_foundp = vars_found; #ifdef RATIONAL_TREES while (to_visit > to_visit_base) { @@ -1075,8 +1031,8 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, #endif return NULL; - error2: - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; +error2: + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; *vars_foundp = vars_found; #ifdef RATIONAL_TREES while (to_visit > to_visit_base) { @@ -1093,8 +1049,8 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, #endif return NULL; - error_tr_overflow: - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; +error_tr_overflow: + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; *vars_foundp = vars_found; #ifdef RATIONAL_TREES while (to_visit > to_visit_base) { @@ -1112,48 +1068,45 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end, return NULL; #if THREADS #undef Yap_REGS -#define Yap_REGS (*Yap_regp) +#define Yap_REGS (*Yap_regp) #endif /* THREADS */ } - #ifdef SFUNC /* * The sparse terms existing in the structure are to be included now. This * means simple copy for constant terms but, some care about variables If - * they have appeared before, we will know by their position number + * they have appeared before, we will know by their position number */ -static void -sf_include(SFKeep *sfp, struct db_globs *dbg) - SFKeep *sfp; +static void sf_include(SFKeep *sfp, struct db_globs *dbg) SFKeep *sfp; { - Term Tm = sfp->SName; - CELL *tp = ArgsOfSFTerm(Tm); - Register Term *StoPoint = ntp; - CELL *displacement = CodeAbs; - CELL arg_no; - Term tvalue; - int j = 3; + Term Tm = sfp->SName; + CELL *tp = ArgsOfSFTerm(Tm); + Register Term *StoPoint = ntp; + CELL *displacement = CodeAbs; + CELL arg_no; + Term tvalue; + int j = 3; if (sfp->SFather != NIL) *(sfp->SFather) = AbsAppl(displacement); *StoPoint++ = FunctorOfTerm(Tm); - db_check_trail(dbg->lr+1); + db_check_trail(dbg->lr + 1); *dbg->lr++ = ToSmall(displacement + 1); - *StoPoint++ = (Term) (displacement + 1); + *StoPoint++ = (Term)(displacement + 1); while (*tp) { arg_no = *tp++; tvalue = Derefa(tp++); if (IsVarTerm(tvalue)) { - if (((VarKeep *) tvalue)->NOfVars != 0) { - *StoPoint++ = arg_no; - db_check_trail(dbg->lr+1); - *dbg->lr++ = ToSmall(displacement + j); - if (((VarKeep *) tvalue)->New == 0) - *StoPoint++ = ((VarKeep *) tvalue)->New = Unsigned(displacement + j); - else - *StoPoint++ = ((VarKeep *) tvalue)->New; - j += 2; + if (((VarKeep *)tvalue)->NOfVars != 0) { + *StoPoint++ = arg_no; + db_check_trail(dbg->lr + 1); + *dbg->lr++ = ToSmall(displacement + j); + if (((VarKeep *)tvalue)->New == 0) + *StoPoint++ = ((VarKeep *)tvalue)->New = Unsigned(displacement + j); + else + *StoPoint++ = ((VarKeep *)tvalue)->New; + j += 2; } } else if (IsAtomicTerm(tvalue)) { *StoPoint++ = arg_no; @@ -1163,7 +1116,7 @@ sf_include(SFKeep *sfp, struct db_globs *dbg) LOCAL_Error_TYPE = TYPE_ERROR_DBTERM; LOCAL_Error_Term = d0; LOCAL_ErrorMessage = "wrong term in SF"; - return(NULL); + return (NULL); } } *StoPoint++ = 0; @@ -1174,27 +1127,23 @@ sf_include(SFKeep *sfp, struct db_globs *dbg) /* * This function is used to check if one of the terms in the idb is the - * constant to_compare + * constant to_compare */ -inline static DBRef -check_if_cons(DBRef p, Term to_compare) -{ - while (p != NIL - && (p->Flags & (DBCode | ErasedMask | DBVar | DBNoVars | DBComplex) - || p->DBT.Entry != Unsigned(to_compare))) +inline static DBRef check_if_cons(DBRef p, Term to_compare) { + while (p != NIL && + (p->Flags & (DBCode | ErasedMask | DBVar | DBNoVars | DBComplex) || + p->DBT.Entry != Unsigned(to_compare))) p = NextDBRef(p); return p; } /* * This function is used to check if one of the terms in the idb is a prolog - * variable + * variable */ -static DBRef -check_if_var(DBRef p) -{ +static DBRef check_if_var(DBRef p) { while (p != NIL && - p->Flags & (DBCode | ErasedMask | DBAtomic | DBNoVars | DBComplex )) + p->Flags & (DBCode | ErasedMask | DBAtomic | DBNoVars | DBComplex)) p = NextDBRef(p); return p; } @@ -1206,22 +1155,19 @@ check_if_var(DBRef p) * comparison is done using the function cmpclls only. The function could * only fail if a functor was matched to a Prolog term, but then, it should * have failed before because the structure of term would have been very - * different + * different */ -static DBRef -check_if_wvars(DBRef p, unsigned int NOfCells, CELL *BTptr) -{ - CELL *memptr; +static DBRef check_if_wvars(DBRef p, unsigned int NOfCells, CELL *BTptr) { + CELL *memptr; do { while (p != NIL && - p->Flags & (DBCode | ErasedMask | DBAtomic | DBNoVars | DBVar)) + p->Flags & (DBCode | ErasedMask | DBAtomic | DBNoVars | DBVar)) p = NextDBRef(p); if (p == NIL) return p; memptr = CellPtr(&(p->DBT.Contents)); - if (NOfCells == p->DBT.NOfCells - && cmpclls(memptr, BTptr, NOfCells)) + if (NOfCells == p->DBT.NOfCells && cmpclls(memptr, BTptr, NOfCells)) return p; else p = NextDBRef(p); @@ -1229,14 +1175,13 @@ check_if_wvars(DBRef p, unsigned int NOfCells, CELL *BTptr) return NIL; } -static int -scheckcells(int NOfCells, register CELL *m1, register CELL *m2, link_entry *lp, register CELL bp) -{ - CELL base = Unsigned(m1); - link_entry *lp1; +static int scheckcells(int NOfCells, register CELL *m1, register CELL *m2, + link_entry *lp, register CELL bp) { + CELL base = Unsigned(m1); + link_entry *lp1; while (NOfCells-- > 0) { - Register CELL r1, r2; + Register CELL r1, r2; r1 = *m1++; r2 = *m2++; @@ -1249,9 +1194,9 @@ scheckcells(int NOfCells, register CELL *m1, register CELL *m2, link_entry *lp, lp1 = lp; r1 = m1 - (CELL *)base; while (*lp1 != r1 && *lp1) - lp1++; + lp1++; if (!(*lp1)) - return FALSE; + return FALSE; /* keep the old link pointer for future search. */ /* vsc: this looks like a bug!!!! */ /* *lp1 = *lp++; */ @@ -1264,31 +1209,29 @@ scheckcells(int NOfCells, register CELL *m1, register CELL *m2, link_entry *lp, /* * the cousin of the previous, but with things a bit more sophisticated. - * mtchcells, if an error was an found, needs to test ........ + * mtchcells, if an error was an found, needs to test ........ */ -static DBRef -check_if_nvars(DBRef p, unsigned int NOfCells, CELL *BTptr, struct db_globs *dbg) -{ - CELL *memptr; +static DBRef check_if_nvars(DBRef p, unsigned int NOfCells, CELL *BTptr, + struct db_globs *dbg) { + CELL *memptr; do { while (p != NIL && - p->Flags & (DBCode | ErasedMask | DBAtomic | DBComplex | DBVar)) + p->Flags & (DBCode | ErasedMask | DBAtomic | DBComplex | DBVar)) p = NextDBRef(p); if (p == NIL) return p; memptr = CellPtr(p->DBT.Contents); - if (scheckcells(NOfCells, memptr, BTptr, dbg->LinkAr, Unsigned(p->DBT.Contents-1))) - return p; - else - p = NextDBRef(p); - } while(TRUE); + if (scheckcells(NOfCells, memptr, BTptr, dbg->LinkAr, + Unsigned(p->DBT.Contents - 1))) + return p; + else + p = NextDBRef(p); + } while (TRUE); return NIL; } -static DBRef -generate_dberror_msg(int errnumb, UInt sz, char *msg) -{ +static DBRef generate_dberror_msg(int errnumb, UInt sz, char *msg) { CACHE_REGS LOCAL_Error_Size = sz; LOCAL_Error_TYPE = errnumb; @@ -1297,31 +1240,31 @@ generate_dberror_msg(int errnumb, UInt sz, char *msg) return NULL; } -static DBRef -CreateDBWithDBRef(Term Tm, DBProp p, struct db_globs *dbg) -{ +static DBRef CreateDBWithDBRef(Term Tm, DBProp p, struct db_globs *dbg) { DBRef pp, dbr = DBRefOfTerm(Tm); DBTerm *ppt; if (p == NULL) { - UInt sz = sizeof(DBTerm)+2*sizeof(CELL); + UInt sz = sizeof(DBTerm) + 2 * sizeof(CELL); ppt = (DBTerm *)AllocDBSpace(sz); if (ppt == NULL) { - return generate_dberror_msg(OUT_OF_HEAP_ERROR, TermNil, "could not allocate heap"); + return generate_dberror_msg(RESOURCE_ERROR_HEAP, TermNil, + "could not allocate heap"); } dbg->sz = sz; Yap_LUClauseSpace += sz; pp = (DBRef)ppt; } else { - UInt sz = DBLength(2*sizeof(DBRef)); + UInt sz = DBLength(2 * sizeof(DBRef)); pp = AllocDBSpace(sz); if (pp == NULL) { - return generate_dberror_msg(OUT_OF_HEAP_ERROR, 0, "could not allocate space"); + return generate_dberror_msg(RESOURCE_ERROR_HEAP, 0, + "could not allocate space"); } Yap_LUClauseSpace += sz; dbg->sz = sz; pp->id = FunctorDBRef; - pp->Flags = DBNoVars|DBComplex|DBWithRefs; + pp->Flags = DBNoVars | DBComplex | DBWithRefs; INIT_LOCK(pp->lock); INIT_DBREF_COUNT(pp); ppt = &(pp->DBT); @@ -1336,26 +1279,27 @@ CreateDBWithDBRef(Term Tm, DBProp p, struct db_globs *dbg) ppt->NOfCells = 0; ppt->Contents[0] = (CELL)NULL; ppt->Contents[1] = (CELL)dbr; - ppt->DBRefs = (DBRef *)(ppt->Contents+2); + ppt->DBRefs = (DBRef *)(ppt->Contents + 2); #ifdef COROUTINING ppt->ag.attachments = 0L; #endif return pp; } -static DBTerm * -CreateDBTermForAtom(Term Tm, UInt extra_size, struct db_globs *dbg) { +static DBTerm *CreateDBTermForAtom(Term Tm, UInt extra_size, + struct db_globs *dbg) { DBTerm *ppt; ADDR ptr; - UInt sz = extra_size+sizeof(DBTerm); + UInt sz = extra_size + sizeof(DBTerm); ptr = (ADDR)AllocDBSpace(sz); if (ptr == NULL) { - return (DBTerm *)generate_dberror_msg(OUT_OF_HEAP_ERROR, 0, "could not allocate space"); + return (DBTerm *)generate_dberror_msg(RESOURCE_ERROR_HEAP, 0, + "could not allocate space"); } Yap_LUClauseSpace += sz; dbg->sz = sz; - ppt = (DBTerm *)(ptr+extra_size); + ppt = (DBTerm *)(ptr + extra_size); ppt->NOfCells = 0; ppt->DBRefs = NULL; #ifdef COROUTINING @@ -1366,20 +1310,19 @@ CreateDBTermForAtom(Term Tm, UInt extra_size, struct db_globs *dbg) { return ppt; } -static DBTerm * -CreateDBTermForVar(UInt extra_size, struct db_globs *dbg) -{ +static DBTerm *CreateDBTermForVar(UInt extra_size, struct db_globs *dbg) { DBTerm *ppt; ADDR ptr; - UInt sz = extra_size+sizeof(DBTerm); + UInt sz = extra_size + sizeof(DBTerm); ptr = (ADDR)AllocDBSpace(sz); if (ptr == NULL) { - return (DBTerm *)generate_dberror_msg(OUT_OF_HEAP_ERROR, 0, "could not allocate space"); + return (DBTerm *)generate_dberror_msg(RESOURCE_ERROR_HEAP, 0, + "could not allocate space"); } Yap_LUClauseSpace += sz; dbg->sz = sz; - ppt = (DBTerm *)(ptr+extra_size); + ppt = (DBTerm *)(ptr + extra_size); ppt->NOfCells = 0; ppt->DBRefs = NULL; #ifdef COROUTINING @@ -1390,18 +1333,19 @@ CreateDBTermForVar(UInt extra_size, struct db_globs *dbg) return ppt; } -static DBRef -CreateDBRefForAtom(Term Tm, DBProp p, int InFlag, struct db_globs *dbg) { - Register DBRef pp; - SMALLUNSGN flag; +static DBRef CreateDBRefForAtom(Term Tm, DBProp p, int InFlag, + struct db_globs *dbg) { + Register DBRef pp; + SMALLUNSGN flag; UInt sz = DBLength(NIL); flag = DBAtomic; - if (InFlag & MkIfNot && (dbg->found_one = check_if_cons(p->First, Tm))) + if (InFlag &MkIfNot && (dbg->found_one = check_if_cons(p->First, Tm))) return dbg->found_one; pp = AllocDBSpace(sz); if (pp == NIL) { - return generate_dberror_msg(OUT_OF_HEAP_ERROR, 0, "could not allocate space"); + return generate_dberror_msg(RESOURCE_ERROR_HEAP, 0, + "could not allocate space"); } Yap_LUClauseSpace += sz; dbg->sz = sz; @@ -1416,25 +1360,26 @@ CreateDBRefForAtom(Term Tm, DBProp p, int InFlag, struct db_globs *dbg) { #ifdef COROUTINING pp->DBT.ag.attachments = 0; #endif - return(pp); + return (pp); } -static DBRef -CreateDBRefForVar(Term Tm, DBProp p, int InFlag, struct db_globs *dbg) { - Register DBRef pp; +static DBRef CreateDBRefForVar(Term Tm, DBProp p, int InFlag, + struct db_globs *dbg) { + Register DBRef pp; UInt sz = DBLength(NULL); - if (InFlag & MkIfNot && (dbg->found_one = check_if_var(p->First))) + if (InFlag &MkIfNot && (dbg->found_one = check_if_var(p->First))) return dbg->found_one; pp = AllocDBSpace(sz); if (pp == NULL) { - return generate_dberror_msg(OUT_OF_HEAP_ERROR, 0, "could not allocate space"); + return generate_dberror_msg(RESOURCE_ERROR_HEAP, 0, + "could not allocate space"); } Yap_LUClauseSpace += sz; dbg->sz = sz; pp->id = FunctorDBRef; pp->Flags = DBVar; - pp->DBT.Entry = (CELL) Tm; + pp->DBT.Entry = (CELL)Tm; pp->Code = NULL; pp->DBT.NOfCells = 0; pp->DBT.DBRefs = NULL; @@ -1446,16 +1391,15 @@ CreateDBRefForVar(Term Tm, DBProp p, int InFlag, struct db_globs *dbg) { return pp; } -static DBRef -CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struct db_globs *dbg) -{ +static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, + UInt extra_size, struct db_globs *dbg) { CACHE_REGS - Register Term tt, *nar = NIL; - SMALLUNSGN flag; + Register Term tt, *nar = NIL; + SMALLUNSGN flag; int NOfLinks = 0; /* place DBRefs in ConsultStack */ - DBRef *TmpRefBase = (DBRef *)LOCAL_TrailTop; - CELL *CodeAbs; /* how much code did we find */ + DBRef *TmpRefBase = (DBRef *)LOCAL_TrailTop; + CELL *CodeAbs; /* how much code did we find */ int vars_found = FALSE; LOCAL_Error_TYPE = YAP_NO_ERROR; @@ -1465,9 +1409,9 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc #ifdef COROUTINING if (!SafeIsAttachedTerm(Tm)) { #endif - DBRef out = (DBRef)CreateDBTermForVar(extra_size, dbg); - *pstat = TRUE; - return out; + DBRef out = (DBRef)CreateDBTermForVar(extra_size, dbg); + *pstat = TRUE; + return out; #ifdef COROUTINING } #endif @@ -1479,9 +1423,9 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc } else { if (IsVarTerm(Tm) #ifdef COROUTINING - && !SafeIsAttachedTerm(Tm) + && !SafeIsAttachedTerm(Tm) #endif - ) { + ) { *pstat = TRUE; return CreateDBRefForVar(Tm, p, InFlag, dbg); } else if (IsAtomOrIntTerm(Tm)) { @@ -1491,65 +1435,62 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc /* next, let's process a compound term */ { DBTerm *ppt, *ppt0; - DBRef pp, pp0; - Term *ntp0, *ntp; - unsigned int NOfCells = 0; + DBRef pp, pp0; + Term *ntp0, *ntp; + unsigned int NOfCells = 0; #ifdef COROUTINING CELL attachments = 0; #endif dbg->tofref = TmpRefBase; - + if (p == NULL) { ADDR ptr = Yap_PreAllocCodeSpace(); - ppt0 = (DBTerm *)(ptr+extra_size); + ppt0 = (DBTerm *)(ptr + extra_size); pp0 = (DBRef)ppt0; } else { pp0 = (DBRef)Yap_PreAllocCodeSpace(); ppt0 = &(pp0->DBT); } - if ((ADDR)ppt0 >= (ADDR)AuxSp-1024) { - LOCAL_Error_Size = (UInt)(extra_size+sizeof(ppt0)); - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return NULL; + if ((ADDR)ppt0 >= (ADDR)AuxSp - 1024) { + LOCAL_Error_Size = (UInt)(extra_size + sizeof(ppt0)); + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return NULL; } ntp0 = ppt0->Contents; - if ((ADDR)TR >= LOCAL_TrailTop-1024) { - LOCAL_Error_Size = 0; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return NULL; + if ((ADDR)TR >= LOCAL_TrailTop - 1024) { + LOCAL_Error_Size = 0; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return NULL; } dbg->lr = dbg->LinkAr = (link_entry *)TR; #ifdef COROUTINING - /* attachment */ + /* attachment */ if (IsVarTerm(Tm)) { tt = (CELL)(ppt0->Contents); - ntp = MkDBTerm(VarOfTerm(Tm), VarOfTerm(Tm), ntp0, ntp0+1, ntp0-1, - &attachments, - &vars_found, - dbg); + ntp = MkDBTerm(VarOfTerm(Tm), VarOfTerm(Tm), ntp0, ntp0 + 1, ntp0 - 1, + &attachments, &vars_found, dbg); if (ntp == NULL) { - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return NULL; + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return NULL; } } else #endif - if (IsPairTerm(Tm)) { + if (IsPairTerm(Tm)) { /* avoid null pointers!! */ tt = AbsPair(ppt0->Contents); - ntp = MkDBTerm(RepPair(Tm), RepPair(Tm)+1, ntp0, ntp0+2, ntp0-1, + ntp = MkDBTerm(RepPair(Tm), RepPair(Tm) + 1, ntp0, ntp0 + 2, ntp0 - 1, #ifdef COROUTINING - &attachments, + &attachments, #endif - &vars_found, dbg); + &vars_found, dbg); if (ntp == NULL) { - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return NULL; + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return NULL; } - } - else { + } else { unsigned int arity; Functor fun; @@ -1557,97 +1498,101 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc /* we need to store the functor manually */ fun = FunctorOfTerm(Tm); if (IsExtensionFunctor(fun)) { - switch((CELL)fun) { - case (CELL)FunctorDouble: - ntp = copy_double(ntp0, RepAppl(Tm)); - break; - case (CELL)FunctorString: - ntp = copy_string(ntp0, RepAppl(Tm)); - break; - case (CELL)FunctorDBRef: - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return CreateDBWithDBRef(Tm, p, dbg); + switch ((CELL)fun) { + case (CELL) FunctorDouble: + ntp = copy_double(ntp0, RepAppl(Tm)); + break; + case (CELL) FunctorString: + ntp = copy_string(ntp0, RepAppl(Tm)); + break; + case (CELL) FunctorDBRef: + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return CreateDBWithDBRef(Tm, p, dbg); #ifdef USE_GMP - case (CELL)FunctorBigInt: - ntp = copy_big_int(ntp0, RepAppl(Tm)); - break; + case (CELL) FunctorBigInt: + ntp = copy_big_int(ntp0, RepAppl(Tm)); + break; #endif - default: /* LongInt */ - ntp = copy_long_int(ntp0, RepAppl(Tm)); - break; - } + default: /* LongInt */ + ntp = copy_long_int(ntp0, RepAppl(Tm)); + break; + } } else { - *ntp0 = (CELL)fun; - arity = ArityOfFunctor(fun); - ntp = MkDBTerm(RepAppl(Tm)+1, - RepAppl(Tm)+arity, - ntp0+1, ntp0+1+arity, ntp0-1, + *ntp0 = (CELL)fun; + arity = ArityOfFunctor(fun); + ntp = MkDBTerm(RepAppl(Tm) + 1, RepAppl(Tm) + arity, ntp0 + 1, + ntp0 + 1 + arity, ntp0 - 1, #ifdef COROUTINING - &attachments, + &attachments, #endif - &vars_found, dbg); - if (ntp == NULL) { - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return NULL; - } + &vars_found, dbg); + if (ntp == NULL) { + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return NULL; + } } - } - CodeAbs = (CELL *)((CELL)ntp-(CELL)ntp0); + } + CodeAbs = (CELL *)((CELL)ntp - (CELL)ntp0); if (LOCAL_Error_TYPE) { Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return NULL; /* Error Situation */ + return NULL; /* Error Situation */ } - NOfCells = ntp - ntp0; /* End Of Code Info */ + NOfCells = ntp - ntp0; /* End Of Code Info */ *dbg->lr++ = 0; NOfLinks = (dbg->lr - dbg->LinkAr); - if (vars_found || InFlag & InQueue ) { + if (vars_found || InFlag & InQueue) { /* * Take into account the fact that one needs an entry - * for the number of links + * for the number of links */ flag = DBComplex; - CodeAbs += (NOfLinks+(sizeof(CELL)/sizeof(BITS32)-1))/(sizeof(CELL)/sizeof(BITS32)); - if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) { - LOCAL_Error_Size = (UInt)DBLength(CodeAbs); - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return NULL; + CodeAbs += (NOfLinks + (sizeof(CELL) / sizeof(BITS32) - 1)) / + (sizeof(CELL) / sizeof(BITS32)); + if ((CELL *)((char *)ntp0 + (CELL)CodeAbs) > AuxSp) { + LOCAL_Error_Size = (UInt)DBLength(CodeAbs); + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return NULL; } - if ((InFlag & MkIfNot) && (dbg->found_one = check_if_wvars(p->First, NOfCells, ntp0))) { - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return dbg->found_one; + if ((InFlag & MkIfNot) && + (dbg->found_one = check_if_wvars(p->First, NOfCells, ntp0))) { + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return dbg->found_one; } } else { flag = DBNoVars; - if ((InFlag & MkIfNot) && (dbg->found_one = check_if_nvars(p->First, NOfCells, ntp0, dbg))) { - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return dbg->found_one; + if ((InFlag & MkIfNot) && + (dbg->found_one = check_if_nvars(p->First, NOfCells, ntp0, dbg))) { + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return dbg->found_one; } } if (dbg->tofref != TmpRefBase) { CodeAbs += (TmpRefBase - dbg->tofref) + 1; - if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) { - LOCAL_Error_Size = (UInt)DBLength(CodeAbs); - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return NULL; + if ((CELL *)((char *)ntp0 + (CELL)CodeAbs) > AuxSp) { + LOCAL_Error_Size = (UInt)DBLength(CodeAbs); + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return NULL; } flag |= DBWithRefs; } -#if SIZEOF_LINK_ENTRY==2 +#if SIZEOF_LINK_ENTRY == 2 if (Unsigned(CodeAbs) >= 0x40000) { Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return generate_dberror_msg(SYSTEM_ERROR, 0, "trying to store term larger than 256KB"); + return generate_dberror_msg(SYSTEM_ERROR_INTERNAL, 0, + "trying to store term larger than 256KB"); } #endif if (p == NULL) { - UInt sz = (CELL)CodeAbs+extra_size+sizeof(DBTerm); + UInt sz = (CELL)CodeAbs + extra_size + sizeof(DBTerm); ADDR ptr = Yap_AllocCodeSpace(sz); - ppt = (DBTerm *)(ptr+extra_size); + ppt = (DBTerm *)(ptr + extra_size); if (ptr == NULL) { - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return generate_dberror_msg(OUT_OF_HEAP_ERROR, sz, "heap crashed against stacks"); + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return generate_dberror_msg(RESOURCE_ERROR_HEAP, sz, + "heap crashed against stacks"); } Yap_LUClauseSpace += sz; dbg->sz = sz; @@ -1656,8 +1601,9 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc UInt sz = DBLength(CodeAbs); pp = AllocDBSpace(sz); if (pp == NULL) { - Yap_ReleasePreAllocCodeSpace((ADDR)pp0); - return generate_dberror_msg(OUT_OF_HEAP_ERROR, sz, "heap crashed against stacks"); + Yap_ReleasePreAllocCodeSpace((ADDR)pp0); + return generate_dberror_msg(RESOURCE_ERROR_HEAP, sz, + "heap crashed against stacks"); } Yap_LUClauseSpace += sz; dbg->sz = sz; @@ -1668,50 +1614,51 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc ppt = &(pp->DBT); } if (flag & DBComplex) { - link_entry *woar; + link_entry *woar; ppt->NOfCells = NOfCells; #ifdef COROUTINING ppt->ag.attachments = attachments; #endif if (pp0 != pp) { - nar = ppt->Contents; - nar = (Term *) cpcells(CellPtr(nar), ntp0, Unsigned(NOfCells)); + nar = ppt->Contents; + nar = (Term *)cpcells(CellPtr(nar), ntp0, Unsigned(NOfCells)); } else { - nar = ppt->Contents + Unsigned(NOfCells); + nar = ppt->Contents + Unsigned(NOfCells); } woar = (link_entry *)nar; - memcpy((void *)woar,(const void *)dbg->LinkAr,(size_t)(NOfLinks*sizeof(link_entry))); + memcpy((void *)woar, (const void *)dbg->LinkAr, + (size_t)(NOfLinks * sizeof(link_entry))); woar += NOfLinks; #ifdef ALIGN_LONGS -#if SIZEOF_INT_P==8 +#if SIZEOF_INT_P == 8 while ((Unsigned(woar) & 7) != 0) - woar++; + woar++; #else if ((Unsigned(woar) & 3) != 0) - woar++; + woar++; #endif #endif - nar = (Term *) (woar); + nar = (Term *)(woar); *pstat = TRUE; } else if (flag & DBNoVars) { if (pp0 != pp) { - nar = (Term *) cpcells(CellPtr(ppt->Contents), ntp0, Unsigned(NOfCells)); + nar = (Term *)cpcells(CellPtr(ppt->Contents), ntp0, Unsigned(NOfCells)); } else { - nar = ppt->Contents + Unsigned(NOfCells); + nar = ppt->Contents + Unsigned(NOfCells); } ppt->NOfCells = NOfCells; } if (ppt != ppt0) { - linkblk(dbg->LinkAr, CellPtr(ppt->Contents-1), (CELL)ppt-(CELL)ppt0); - ppt->Entry = AdjustIDBPtr(tt,(CELL)ppt-(CELL)ppt0); + linkblk(dbg->LinkAr, CellPtr(ppt->Contents - 1), (CELL)ppt - (CELL)ppt0); + ppt->Entry = AdjustIDBPtr(tt, (CELL)ppt - (CELL)ppt0); #ifdef COROUTINING if (attachments) - ppt->ag.attachments = AdjustIDBPtr(attachments,(CELL)ppt-(CELL)ppt0); + ppt->ag.attachments = AdjustIDBPtr(attachments, (CELL)ppt - (CELL)ppt0); else - ppt->ag.attachments = 0L; + ppt->ag.attachments = 0L; #endif - } else { + } else { ppt->Entry = tt; #ifdef COROUTINING ppt->ag.attachments = attachments; @@ -1722,22 +1669,20 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc *rfnar++ = NULL; while (ptr != dbg->tofref) - *rfnar++ = *--ptr; + *rfnar++ = *--ptr; ppt->DBRefs = rfnar; } else { ppt->DBRefs = NULL; - } + } Yap_ReleasePreAllocCodeSpace((ADDR)pp0); return pp; } } -static DBRef -record(int Flag, Term key, Term t_data, Term t_code USES_REGS) -{ - Register Term twork = key; +static DBRef record(int Flag, Term key, Term t_data, Term t_code USES_REGS) { + Register Term twork = key; Register DBProp p; - Register DBRef x; + Register DBRef x; int needs_vars; struct db_globs dbg; @@ -1746,7 +1691,8 @@ record(int Flag, Term key, Term t_data, Term t_code USES_REGS) #ifdef SFUNC FathersPlace = NIL; #endif - if (EndOfPAEntr(p = FetchDBPropFromKey(twork, Flag & MkCode, TRUE, "record/3"))) { + if (EndOfPAEntr( + p = FetchDBPropFromKey(twork, Flag & MkCode, TRUE, "record/3"))) { return NULL; } if ((x = CreateDBStruct(t_data, p, Flag, &needs_vars, 0, &dbg)) == NULL) { @@ -1755,7 +1701,7 @@ record(int Flag, Term key, Term t_data, Term t_code USES_REGS) if ((Flag & MkIfNot) && dbg.found_one) return NULL; TRAIL_REF(x); - if (x->Flags & (DBNoVars|DBComplex)) + if (x->Flags & (DBNoVars | DBComplex)) x->Mask = EvalMasks(t_data, &x->Key); else x->Mask = x->Key = 0; @@ -1803,18 +1749,16 @@ record(int Flag, Term key, Term t_data, Term t_code USES_REGS) p->Last = x; } if (Flag & MkCode) { - x->Code = (yamop *) IntegerOfTerm(t_code); + x->Code = (yamop *)IntegerOfTerm(t_code); } WRITE_UNLOCK(p->DBRWLock); return x; } /* add a new entry next to an old one */ -static DBRef -record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS) -{ +static DBRef record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS) { Register DBProp p; - Register DBRef x; + Register DBRef x; int needs_vars; struct db_globs dbg; @@ -1827,7 +1771,7 @@ record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS) return NULL; } TRAIL_REF(x); - if (x->Flags & (DBNoVars|DBComplex)) + if (x->Flags & (DBNoVars | DBComplex)) x->Mask = EvalMasks(t_data, &x->Key); else x->Mask = x->Key = 0; @@ -1883,16 +1827,13 @@ record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS) r0->Next = x; } if (Flag & WithRef) { - x->Code = (yamop *) IntegerOfTerm(t_code); + x->Code = (yamop *)IntegerOfTerm(t_code); } WRITE_UNLOCK(p->DBRWLock); return x; } - -static LogUpdClause * -new_lu_db_entry(Term t, PredEntry *pe) -{ +static LogUpdClause *new_lu_db_entry(Term t, PredEntry *pe) { CACHE_REGS DBTerm *x; LogUpdClause *cl; @@ -1902,16 +1843,17 @@ new_lu_db_entry(Term t, PredEntry *pe) int d_flag = 0; #if MULTIPLE_STACKS - /* we cannot allow sharing between threads (for now) */ + /* we cannot allow sharing between threads (for now) */ if (!pe || !(pe->PredFlags & ThreadLocalPredFlag)) d_flag |= InQueue; #endif LOCAL_s_dbg = &dbg; - ipc = NEXTOP(((LogUpdClause *)NULL)->ClCode,e); - if ((x = (DBTerm *)CreateDBStruct(t, NULL, d_flag, &needs_vars, (UInt)ipc, &dbg)) == NULL) { + ipc = NEXTOP(((LogUpdClause *)NULL)->ClCode, e); + if ((x = (DBTerm *)CreateDBStruct(t, NULL, d_flag, &needs_vars, (UInt)ipc, + &dbg)) == NULL) { return NULL; /* crash */ } - cl = (LogUpdClause *)((ADDR)x-(UInt)ipc); + cl = (LogUpdClause *)((ADDR)x - (UInt)ipc); ipc = cl->ClCode; cl->Id = FunctorDBRef; cl->ClFlags = LogUpdMask; @@ -1926,13 +1868,14 @@ new_lu_db_entry(Term t, PredEntry *pe) if (pe->TimeStampOfPred >= TIMESTAMP_RESET) Yap_UpdateTimestamps(pe); ++pe->TimeStampOfPred; - /* fprintf(stderr,"+ %x--%d--%ul\n",pe,pe->TimeStampOfPred,pe->ArityOfPE);*/ + /* fprintf(stderr,"+ + * %x--%d--%ul\n",pe,pe->TimeStampOfPred,pe->ArityOfPE);*/ pe->LastCallOfPred = LUCALL_ASSERT; cl->ClTimeStart = pe->TimeStampOfPred; } else { cl->ClTimeStart = 0L; } - cl->ClTimeEnd = TIMESTAMP_EOT; + cl->ClTimeEnd = TIMESTAMP_EOT; #if MULTIPLE_STACKS // INIT_LOCK(cl->ClLock); INIT_CLREF_COUNT(cl); @@ -1947,10 +1890,7 @@ new_lu_db_entry(Term t, PredEntry *pe) return cl; } - -LogUpdClause * -Yap_new_ludbe(Term t, PredEntry *pe, UInt nargs) -{ +LogUpdClause *Yap_new_ludbe(Term t, PredEntry *pe, UInt nargs) { CACHE_REGS LogUpdClause *x; @@ -1959,45 +1899,42 @@ Yap_new_ludbe(Term t, PredEntry *pe, UInt nargs) if (LOCAL_Error_TYPE == YAP_NO_ERROR) { break; } else { - XREGS[nargs+1] = t; - if (recover_from_record_error(nargs+1)) { - t = Deref(XREGS[nargs+1]); + XREGS[nargs + 1] = t; + if (recover_from_record_error(nargs + 1)) { + t = Deref(XREGS[nargs + 1]); } else { - return FALSE; + return FALSE; } } } return x; } -static LogUpdClause * -record_lu(PredEntry *pe, Term t, int position) -{ +static LogUpdClause *record_lu(PredEntry *pe, Term t, int position) { LogUpdClause *cl; - + if ((cl = new_lu_db_entry(t, pe)) == NULL) { return NULL; } { - Yap_inform_profiler_of_clause(cl, (char *)cl+cl->ClSize, pe, GPROF_NEW_LU_CLAUSE); + Yap_inform_profiler_of_clause(cl, (char *)cl + cl->ClSize, pe, + GPROF_NEW_LU_CLAUSE); } Yap_add_logupd_clause(pe, cl, (position == MkFirst ? 2 : 0)); return cl; } -static LogUpdClause * -record_lu_at(int position, LogUpdClause *ocl, Term t) -{ +static LogUpdClause *record_lu_at(int position, LogUpdClause *ocl, Term t) { LogUpdClause *cl; PredEntry *pe; pe = ocl->ClPred; - PELOCK(62,pe); - if ((cl = new_lu_db_entry(t,pe)) == NULL) { + PELOCK(62, pe); + if ((cl = new_lu_db_entry(t, pe)) == NULL) { UNLOCK(pe->PELock); return NULL; } - if(pe->cs.p_code.NOfClauses > 1) + if (pe->cs.p_code.NOfClauses > 1) Yap_RemoveIndexation(pe); if (position == MkFirst) { /* add before current clause */ @@ -2025,30 +1962,27 @@ record_lu_at(int position, LogUpdClause *ocl, Term t) pe->cs.p_code.NOfClauses++; if (pe->cs.p_code.NOfClauses > 1) { pe->OpcodeOfPred = INDEX_OPCODE; - pe->CodeOfPred = (yamop *)(&(pe->OpcodeOfPred)); + pe->CodeOfPred = (yamop *)(&(pe->OpcodeOfPred)); } UNLOCK(pe->PELock); return cl; } - /* recorda(+Functor,+Term,-Ref) */ -static Int -p_rcda( USES_REGS1 ) -{ +static Int p_rcda(USES_REGS1) { /* Idiotic xlc's cpp does not work with ARG1 within MkDBRefTerm */ - Term TRef, t1 = Deref(ARG1); + Term TRef, t1 = Deref(ARG1); PredEntry *pe = NULL; if (!IsVarTerm(Deref(ARG3))) return (FALSE); pe = find_lu_entry(t1); LOCAL_Error_Size = 0; - restart_record: +restart_record: if (pe) { LogUpdClause *cl; - PELOCK(61,pe); + PELOCK(61, pe); cl = record_lu(pe, Deref(ARG2), MkFirst); if (cl != NULL) { TRAIL_CLREF(cl); @@ -2078,15 +2012,13 @@ p_rcda( USES_REGS1 ) } /* '$recordap'(+Functor,+Term,-Ref) */ -static Int -p_rcdap( USES_REGS1 ) -{ - Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2); +static Int p_rcdap(USES_REGS1) { + Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2); if (!IsVarTerm(Deref(ARG3))) return FALSE; LOCAL_Error_Size = 0; - restart_record: +restart_record: TRef = MkDBRefTerm(record(MkFirst | MkCode, t1, t2, Unsigned(0) PASS_REGS)); if (LOCAL_Error_TYPE != YAP_NO_ERROR) { @@ -2102,42 +2034,41 @@ p_rcdap( USES_REGS1 ) } /* recorda_at(+DBRef,+Term,-Ref) */ -/** @pred recorda_at(+ _R0_, _T_,- _R_) +/** @pred recorda_at(+ _R0_, _T_,- _R_) Makes term _T_ the record preceding record with reference _R0_, and unifies _R_ with its reference. - + */ -static Int -p_rcda_at( USES_REGS1 ) -{ +static Int p_rcda_at(USES_REGS1) { /* Idiotic xlc's cpp does not work with ARG1 within MkDBRefTerm */ - Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2); - DBRef dbr; + Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2); + DBRef dbr; if (!IsVarTerm(Deref(ARG3))) return FALSE; if (IsVarTerm(t1)) { - Yap_Error(INSTANTIATION_ERROR, t1, "recorda_at/3"); - return FALSE; + Yap_Error(INSTANTIATION_ERROR, t1, "recorda_at/3"); + return FALSE; } if (!IsDBRefTerm(t1)) { - Yap_Error(TYPE_ERROR_DBREF, t1, "recorda_at/3"); - return FALSE; + Yap_Error(TYPE_ERROR_DBREF, t1, "recorda_at/3"); + return FALSE; } LOCAL_Error_Size = 0; - restart_record: +restart_record: dbr = DBRefOfTerm(t1); if (dbr->Flags & ErasedMask) { - /* doesn't make sense */ + /* doesn't make sense */ return FALSE; } if (dbr->Flags & LogUpdMask) { TRef = MkDBRefTerm((DBRef)record_lu_at(MkFirst, (LogUpdClause *)dbr, t2)); - } else { - TRef = MkDBRefTerm(record_at(MkFirst, DBRefOfTerm(t1), t2, Unsigned(0) PASS_REGS)); + } else { + TRef = MkDBRefTerm( + record_at(MkFirst, DBRefOfTerm(t1), t2, Unsigned(0) PASS_REGS)); } if (LOCAL_Error_TYPE != YAP_NO_ERROR) { if (recover_from_record_error(3)) { @@ -2152,27 +2083,25 @@ p_rcda_at( USES_REGS1 ) } /* recordz(+Functor,+Term,-Ref) */ -/** @pred recordz(+ _K_, _T_,- _R_) +/** @pred recordz(+ _K_, _T_,- _R_) Makes term _T_ the last record under key _K_ and unifies _R_ with its reference. - + */ -static Int -p_rcdz( USES_REGS1 ) -{ - Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2); +static Int p_rcdz(USES_REGS1) { + Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2); PredEntry *pe; if (!IsVarTerm(Deref(ARG3))) return (FALSE); pe = find_lu_entry(t1); LOCAL_Error_Size = 0; - restart_record: +restart_record: if (pe) { LogUpdClause *cl; - PELOCK(62,pe); + PELOCK(62, pe); cl = record_lu(pe, t2, MkLast); if (cl != NULL) { TRAIL_CLREF(cl); @@ -2204,18 +2133,16 @@ p_rcdz( USES_REGS1 ) } /* recordz(+Functor,+Term,-Ref) */ -Int -Yap_Recordz(Atom at, Term t2) -{ +Int Yap_Recordz(Atom at, Term t2) { CACHE_REGS PredEntry *pe; pe = find_lu_entry(MkAtomTerm(at)); LOCAL_Error_Size = 0; - restart_record: +restart_record: if (pe) { record_lu(pe, t2, MkLast); - } else { + } else { record(MkLast, MkAtomTerm(at), t2, Unsigned(0) PASS_REGS); } if (LOCAL_Error_TYPE != YAP_NO_ERROR) { @@ -2231,15 +2158,13 @@ Yap_Recordz(Atom at, Term t2) } /* '$recordzp'(+Functor,+Term,-Ref) */ -static Int -p_rcdzp( USES_REGS1 ) -{ - Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2); +static Int p_rcdzp(USES_REGS1) { + Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2); if (!IsVarTerm(Deref(ARG3))) return (FALSE); LOCAL_Error_Size = 0; - restart_record: +restart_record: TRef = MkDBRefTerm(record(MkLast | MkCode, t1, t2, Unsigned(0) PASS_REGS)); if (LOCAL_Error_TYPE != YAP_NO_ERROR) { if (recover_from_record_error(3)) { @@ -2254,36 +2179,34 @@ p_rcdzp( USES_REGS1 ) } /* recordz_at(+Functor,+Term,-Ref) */ -/** @pred recordz_at(+ _R0_, _T_,- _R_) +/** @pred recordz_at(+ _R0_, _T_,- _R_) Makes term _T_ the record following record with reference _R0_, and unifies _R_ with its reference. - + */ -static Int -p_rcdz_at( USES_REGS1 ) -{ +static Int p_rcdz_at(USES_REGS1) { /* Idiotic xlc's cpp does not work with ARG1 within MkDBRefTerm */ - Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2); - DBRef dbr; + Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2); + DBRef dbr; if (!IsVarTerm(Deref(ARG3))) return (FALSE); if (IsVarTerm(t1)) { - Yap_Error(INSTANTIATION_ERROR, t1, "recordz_at/3"); - return FALSE; + Yap_Error(INSTANTIATION_ERROR, t1, "recordz_at/3"); + return FALSE; } if (!IsDBRefTerm(t1)) { - Yap_Error(TYPE_ERROR_DBREF, t1, "recordz_at/3"); - return FALSE; + Yap_Error(TYPE_ERROR_DBREF, t1, "recordz_at/3"); + return FALSE; } LOCAL_Error_Size = 0; - restart_record: +restart_record: dbr = DBRefOfTerm(t1); if (dbr->Flags & ErasedMask) { - /* doesn't make sense */ + /* doesn't make sense */ return FALSE; } if (dbr->Flags & LogUpdMask) { @@ -2304,9 +2227,7 @@ p_rcdz_at( USES_REGS1 ) } /* '$record_stat_source'(+Functor,+Term) */ -static Int -p_rcdstatp( USES_REGS1 ) -{ +static Int p_rcdstatp(USES_REGS1) { Term t1 = Deref(ARG1), t2 = Deref(ARG2), t3 = Deref(ARG3); int mk_first; Term TRef; @@ -2317,9 +2238,10 @@ p_rcdstatp( USES_REGS1 ) return (FALSE); mk_first = ((IntOfTerm(t3) % 4) == 2); LOCAL_Error_Size = 0; - restart_record: +restart_record: if (mk_first) - TRef = MkDBRefTerm(record(MkFirst | MkCode, t1, t2, MkIntTerm(0) PASS_REGS)); + TRef = + MkDBRefTerm(record(MkFirst | MkCode, t1, t2, MkIntTerm(0) PASS_REGS)); else TRef = MkDBRefTerm(record(MkLast | MkCode, t1, t2, MkIntTerm(0) PASS_REGS)); if (LOCAL_Error_TYPE != YAP_NO_ERROR) { @@ -2336,19 +2258,16 @@ p_rcdstatp( USES_REGS1 ) } /* '$recordap'(+Functor,+Term,-Ref,+CRef) */ -static Int -p_drcdap( USES_REGS1 ) -{ - Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2), t4 = Deref(ARG4); +static Int p_drcdap(USES_REGS1) { + Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2), t4 = Deref(ARG4); if (!IsVarTerm(Deref(ARG3))) return (FALSE); if (IsVarTerm(t4) || !IsIntegerTerm(t4)) return (FALSE); LOCAL_Error_Size = 0; - restart_record: - TRef = MkDBRefTerm(record(MkFirst | MkCode | WithRef, - t1, t2, t4 PASS_REGS)); +restart_record: + TRef = MkDBRefTerm(record(MkFirst | MkCode | WithRef, t1, t2, t4 PASS_REGS)); if (LOCAL_Error_TYPE != YAP_NO_ERROR) { if (recover_from_record_error(4)) { t1 = Deref(ARG1); @@ -2363,19 +2282,16 @@ p_drcdap( USES_REGS1 ) } /* '$recordzp'(+Functor,+Term,-Ref,+CRef) */ -static Int -p_drcdzp( USES_REGS1 ) -{ - Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2), t4 = Deref(ARG4); +static Int p_drcdzp(USES_REGS1) { + Term TRef, t1 = Deref(ARG1), t2 = Deref(ARG2), t4 = Deref(ARG4); if (!IsVarTerm(Deref(ARG3))) return (FALSE); if (IsVarTerm(t4) || !IsIntegerTerm(t4)) return (FALSE); - restart_record: +restart_record: LOCAL_Error_Size = 0; - TRef = MkDBRefTerm(record(MkLast | MkCode | WithRef, - t1, t2, t4 PASS_REGS)); + TRef = MkDBRefTerm(record(MkLast | MkCode | WithRef, t1, t2, t4 PASS_REGS)); if (LOCAL_Error_TYPE != YAP_NO_ERROR) { if (recover_from_record_error(4)) { t1 = Deref(ARG1); @@ -2389,15 +2305,13 @@ p_drcdzp( USES_REGS1 ) return Yap_unify(ARG3, TRef); } -static Int -p_still_variant( USES_REGS1 ) -{ +static Int p_still_variant(USES_REGS1) { CELL *old_h = B->cp_h; - tr_fr_ptr old_tr = B->cp_tr; + tr_fr_ptr old_tr = B->cp_tr; Term t1 = Deref(ARG1), t2 = Deref(ARG2); DBTerm *dbt; DBRef dbr; - + if (IsVarTerm(t1) || !IsDBRefTerm(t1)) { return (FALSE); /* limited sanity checking */ @@ -2414,9 +2328,9 @@ p_still_variant( USES_REGS1 ) if (dbr->Flags & LogUpdMask) { LogUpdClause *cl = (LogUpdClause *)dbr; - if (old_tr == TR-1) { + if (old_tr == TR - 1) { if (TrailTerm(old_tr) != CLREF_TO_TRENTRY(cl)) - return FALSE; + return FALSE; } else if (old_tr != TR) return FALSE; if (Yap_op_from_opcode(cl->ClCode->opc) == _unify_idb_term) { @@ -2425,12 +2339,12 @@ p_still_variant( USES_REGS1 ) dbt = cl->lusl.ClSource; } } else { - if (old_tr == TR-1) { + if (old_tr == TR - 1) { if (TrailTerm(old_tr) != REF_TO_TRENTRY(dbr)) - return FALSE; + return FALSE; } else if (old_tr != TR) return FALSE; - if (dbr->Flags & (DBNoVars|DBAtomic)) + if (dbr->Flags & (DBNoVars | DBAtomic)) return TRUE; if (dbr->Flags & DBVar) return IsVarTerm(t2); @@ -2441,73 +2355,68 @@ p_still_variant( USES_REGS1 ) were bound */ { - link_entry *lp = (link_entry *)(dbt->Contents+dbt->NOfCells); + link_entry *lp = (link_entry *)(dbt->Contents + dbt->NOfCells); link_entry link; if (!dbt->NOfCells) { return IsVarTerm(t2); } while ((link = *lp++)) { - Term t2 = Deref(old_h[link-1]); - if (IsUnboundVar(dbt->Contents+(link-1))) { - if (IsVarTerm(t2)) { - Yap_unify(t2,MkAtomTerm(AtomFoundVar)); - } else { - return FALSE; - } + Term t2 = Deref(old_h[link - 1]); + if (IsUnboundVar(dbt->Contents + (link - 1))) { + if (IsVarTerm(t2)) { + Yap_unify(t2, MkAtomTerm(AtomFoundVar)); + } else { + return FALSE; + } } } } return TRUE; } - #ifdef COROUTINING -static int -copy_attachments(CELL *ts USES_REGS) -{ +static int copy_attachments(CELL *ts USES_REGS) { /* we will change delayed vars, and that also means the trail */ tr_fr_ptr tr0 = TR; while (TRUE) { /* store away in case there is an overflow */ - if (GLOBAL_attas[IntegerOfTerm(ts[2])].term_to_op(ts[1], ts[0] PASS_REGS) == FALSE) { + if (GLOBAL_attas[IntegerOfTerm(ts[2])].term_to_op(ts[1], ts[0] PASS_REGS) == + FALSE) { /* oops, we did not have enough space to copy the elements */ /* reset queue of woken up goals */ TR = tr0; return FALSE; } - if (ts[3] == TermNil) return TRUE; - ts = RepAppl(ts[3])+1; + if (ts[3] == TermNil) + return TRUE; + ts = RepAppl(ts[3]) + 1; } } #endif -static Term -GetDBLUKey(PredEntry *ap) -{ - PELOCK(63,ap); +static Term GetDBLUKey(PredEntry *ap) { + PELOCK(63, ap); if (ap->PredFlags & NumberDBPredFlag) { CACHE_REGS Int id = ap->src.IndxId; UNLOCK(ap->PELock); return MkIntegerTerm(id); } else if (ap->PredFlags & AtomDBPredFlag || - (ap->ModuleOfPred != IDB_MODULE && ap->ArityOfPE == 0)) { + (ap->ModuleOfPred != IDB_MODULE && ap->ArityOfPE == 0)) { Atom at = (Atom)ap->FunctorOfPred; UNLOCK(ap->PELock); return MkAtomTerm(at); } else { Functor f = ap->FunctorOfPred; UNLOCK(ap->PELock); - return Yap_MkNewApplTerm(f,ArityOfFunctor(f)); + return Yap_MkNewApplTerm(f, ArityOfFunctor(f)); } } -static int -UnifyDBKey(DBRef DBSP, PropFlags flags, Term t) -{ +static int UnifyDBKey(DBRef DBSP, PropFlags flags, Term t) { DBProp p = DBSP->Parent; Term t1, tf; @@ -2516,7 +2425,7 @@ UnifyDBKey(DBRef DBSP, PropFlags flags, Term t) if (p->ArityOfDB == 0) { t1 = MkAtomTerm((Atom)(p->FunctorOfDB)); } else { - t1 = Yap_MkNewApplTerm(p->FunctorOfDB,p->ArityOfDB); + t1 = Yap_MkNewApplTerm(p->FunctorOfDB, p->ArityOfDB); } if ((p->KindOfPE & CodeDBBit) && (flags & CodeDBBit)) { Term t[2]; @@ -2532,13 +2441,10 @@ UnifyDBKey(DBRef DBSP, PropFlags flags, Term t) return FALSE; } READ_UNLOCK(p->DBRWLock); - return Yap_unify(tf,t); + return Yap_unify(tf, t); } - -static int -UnifyDBNumber(DBRef DBSP, Term t) -{ +static int UnifyDBNumber(DBRef DBSP, Term t) { CACHE_REGS DBProp p = DBSP->Parent; DBRef ref; @@ -2547,25 +2453,23 @@ UnifyDBNumber(DBRef DBSP, Term t) READ_LOCK(p->DBRWLock); ref = p->First; while (ref != NIL) { - if (ref == DBSP) break; - if (!DEAD_REF(ref)) i++; + if (ref == DBSP) + break; + if (!DEAD_REF(ref)) + i++; ref = ref->Next; } if (ref == NIL) return FALSE; READ_UNLOCK(p->DBRWLock); - return Yap_unify(MkIntegerTerm(i),t); + return Yap_unify(MkIntegerTerm(i), t); } -Int -Yap_unify_immediate_ref(DBRef ref USES_REGS) -{ +Int Yap_unify_immediate_ref(DBRef ref USES_REGS) { // old immediate semantics style LOCK(ref->lock); - if (ref == NULL - || DEAD_REF(ref) - || !UnifyDBKey(ref,0,ARG1) - || !UnifyDBNumber(ref,ARG2)) { + if (ref == NULL || DEAD_REF(ref) || !UnifyDBKey(ref, 0, ARG1) || + !UnifyDBNumber(ref, ARG2)) { UNLOCK(ref->lock); return FALSE; } else { @@ -2574,12 +2478,10 @@ Yap_unify_immediate_ref(DBRef ref USES_REGS) } } -static Term -GetDBTerm(DBTerm *DBSP, int src USES_REGS) -{ +static Term GetDBTerm(DBTerm *DBSP, int src USES_REGS) { Term t = DBSP->Entry; - if (IsVarTerm(t) + if (IsVarTerm(t) #if COROUTINING && !DBSP->ag.attachments #endif @@ -2588,25 +2490,26 @@ GetDBTerm(DBTerm *DBSP, int src USES_REGS) } else if (IsAtomOrIntTerm(t)) { return t; } else { - CELL *HOld = HR; - CELL *HeapPtr; - CELL *pt; - CELL NOf; + CELL *HOld = HR; + CELL *HeapPtr; + CELL *pt; + CELL NOf; if (!(NOf = DBSP->NOfCells)) { return t; } pt = CellPtr(DBSP->Contents); - CalculateStackGap( PASS_REGS1 ); - if (HR+NOf > ASP-EventFlag/sizeof(CELL)) { + CalculateStackGap(PASS_REGS1); + if (HR + NOf > ASP - EventFlag / sizeof(CELL)) { if (LOCAL_PrologMode & InErrorMode) { - if (HR+NOf > ASP) - fprintf(stderr, "\n\n [ FATAL ERROR: No Stack for Error Handling ]\n"); - Yap_exit( 1); + if (HR + NOf > ASP) + fprintf(stderr, + "\n\n [ FATAL ERROR: No Stack for Error Handling ]\n"); + Yap_exit(1); } else { - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; - LOCAL_Error_Size = NOf*sizeof(CELL); - return (Term)0; + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; + LOCAL_Error_Size = NOf * sizeof(CELL); + return (Term)0; } } HeapPtr = cpcells(HOld, pt, NOf); @@ -2614,33 +2517,32 @@ GetDBTerm(DBTerm *DBSP, int src USES_REGS) HR = HeapPtr; { link_entry *lp = (link_entry *)pt; - linkblk(lp, HOld-1, (CELL)HOld-(CELL)(DBSP->Contents)); + linkblk(lp, HOld - 1, (CELL)HOld - (CELL)(DBSP->Contents)); } #ifdef COROUTINING - if (DBSP->ag.attachments != 0L && !src) { - if (!copy_attachments((CELL *)AdjustIDBPtr(DBSP->ag.attachments,(CELL)HOld-(CELL)(DBSP->Contents)) PASS_REGS)) { - HR = HOld; - LOCAL_Error_TYPE = OUT_OF_ATTVARS_ERROR; - LOCAL_Error_Size = 0; - return (Term)0; + if (DBSP->ag.attachments != 0L && !src) { + if (!copy_attachments((CELL *)AdjustIDBPtr( + DBSP->ag.attachments, (CELL)HOld - (CELL)(DBSP->Contents)) + PASS_REGS)) { + HR = HOld; + LOCAL_Error_TYPE = RESOURCE_ERROR_ATTRIBUTED_VARIABLES; + LOCAL_Error_Size = 0; + return (Term)0; } } #endif - return AdjustIDBPtr(t,Unsigned(HOld)-(CELL)(DBSP->Contents)); + return AdjustIDBPtr(t, Unsigned(HOld) - (CELL)(DBSP->Contents)); } } -static Term -GetDBTermFromDBEntry(DBRef DBSP USES_REGS) -{ +static Term GetDBTermFromDBEntry(DBRef DBSP USES_REGS) { if (DBSP->Flags & (DBNoVars | DBAtomic)) return DBSP->DBT.Entry; return GetDBTerm(&(DBSP->DBT), FALSE PASS_REGS); } -static void -init_int_keys( void ) { - INT_KEYS = (Prop *)Yap_AllocCodeSpace(sizeof(Prop)*INT_KEYS_SIZE); +static void init_int_keys(void) { + INT_KEYS = (Prop *)Yap_AllocCodeSpace(sizeof(Prop) * INT_KEYS_SIZE); if (INT_KEYS != NULL) { UInt i = 0; Prop *p = INT_KEYS; @@ -2648,13 +2550,12 @@ init_int_keys( void ) { p[0] = NIL; p++; } - Yap_LUClauseSpace += sizeof(Prop)*INT_KEYS_SIZE; + Yap_LUClauseSpace += sizeof(Prop) * INT_KEYS_SIZE; } } -static void -init_int_lu_keys( void ) { - INT_LU_KEYS = (Prop *)Yap_AllocCodeSpace(sizeof(Prop)*INT_KEYS_SIZE); +static void init_int_lu_keys(void) { + INT_LU_KEYS = (Prop *)Yap_AllocCodeSpace(sizeof(Prop) * INT_KEYS_SIZE); if (INT_LU_KEYS != NULL) { UInt i = 0; Prop *p = INT_LU_KEYS; @@ -2662,12 +2563,11 @@ init_int_lu_keys( void ) { p[0] = NULL; p++; } - Yap_LUClauseSpace += sizeof(Prop)*INT_KEYS_SIZE; + Yap_LUClauseSpace += sizeof(Prop) * INT_KEYS_SIZE; } } -static int -resize_int_keys(UInt new_size) { +static int resize_int_keys(UInt new_size) { CACHE_REGS Prop *new; UInt i; @@ -2679,15 +2579,15 @@ resize_int_keys(UInt new_size) { YAPLeaveCriticalSection(); return TRUE; } - new = (Prop *)Yap_AllocCodeSpace(sizeof(Prop)*new_size); + new = (Prop *)Yap_AllocCodeSpace(sizeof(Prop) * new_size); if (new == NULL) { YAPLeaveCriticalSection(); - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "could not allocate space"; return FALSE; } - Yap_LUClauseSpace += sizeof(Prop)*new_size; + Yap_LUClauseSpace += sizeof(Prop) * new_size; for (i = 0; i < new_size; i++) { new[i] = NIL; } @@ -2695,16 +2595,16 @@ resize_int_keys(UInt new_size) { if (INT_KEYS[i] != NIL) { Prop p0 = INT_KEYS[i]; while (p0 != NIL) { - DBProp p = RepDBProp(p0); - CELL key = (CELL)(p->FunctorOfDB); - UInt hash_key = (CELL)key % new_size; - p0 = p->NextOfPE; - p->NextOfPE = new[hash_key]; - new[hash_key] = AbsDBProp(p); + DBProp p = RepDBProp(p0); + CELL key = (CELL)(p->FunctorOfDB); + UInt hash_key = (CELL)key % new_size; + p0 = p->NextOfPE; + p->NextOfPE = new[hash_key]; + new[hash_key] = AbsDBProp(p); } } } - Yap_LUClauseSpace -= sizeof(Prop)*old_size; + Yap_LUClauseSpace -= sizeof(Prop) * old_size; Yap_FreeCodeSpace((char *)INT_KEYS); INT_KEYS = new; INT_KEYS_SIZE = new_size; @@ -2715,41 +2615,32 @@ resize_int_keys(UInt new_size) { return TRUE; } -static PredEntry * -find_lu_int_key(Int key) -{ +static PredEntry *find_lu_int_key(Int key) { UInt hash_key = (CELL)key % INT_KEYS_SIZE; Prop p0; - + if (INT_LU_KEYS != NULL) { p0 = INT_LU_KEYS[hash_key]; while (p0) { PredEntry *pe = RepPredProp(p0); if (pe->src.IndxId == key) { - return pe; + return pe; } p0 = pe->NextOfPE; } } - if (UPDATE_MODE == UPDATE_MODE_LOGICAL && - find_int_key(key) == NULL) { + if (UPDATE_MODE == UPDATE_MODE_LOGICAL && find_int_key(key) == NULL) { return new_lu_int_key(key); } return NULL; } -PredEntry * -Yap_FindLUIntKey(Int key) -{ - return find_lu_int_key(key); -} +PredEntry *Yap_FindLUIntKey(Int key) { return find_lu_int_key(key); } -static DBProp -find_int_key(Int key) -{ +static DBProp find_int_key(Int key) { UInt hash_key = (CELL)key % INT_KEYS_SIZE; Prop p0; - + if (INT_KEYS == NULL) { return NULL; } @@ -2763,19 +2654,17 @@ find_int_key(Int key) return NULL; } -static PredEntry * -new_lu_int_key(Int key) -{ +static PredEntry *new_lu_int_key(Int key) { UInt hash_key = (CELL)key % INT_KEYS_SIZE; PredEntry *p; Prop p0; Atom ae; - + if (INT_LU_KEYS == NULL) { init_int_lu_keys(); if (INT_LU_KEYS == NULL) { CACHE_REGS - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "could not allocate space"; return NULL; @@ -2783,11 +2672,11 @@ new_lu_int_key(Int key) } ae = AtomDInteger; WRITE_LOCK(ae->ARWLock); - p0 = Yap_NewPredPropByAtom(ae,IDB_MODULE); + p0 = Yap_NewPredPropByAtom(ae, IDB_MODULE); p = RepPredProp(p0); p->NextOfPE = INT_LU_KEYS[hash_key]; p->src.IndxId = key; - p->PredFlags |= LogUpdatePredFlag|NumberDBPredFlag; + p->PredFlags |= LogUpdatePredFlag | NumberDBPredFlag; p->ArityOfPE = 3; p->OpcodeOfPred = Yap_opcode(_op_fail); p->cs.p_code.TrueCodeOfPred = p->CodeOfPred = FAILCODE; @@ -2795,9 +2684,7 @@ new_lu_int_key(Int key) return p; } -static PredEntry * -new_lu_entry(Term t) -{ +static PredEntry *new_lu_entry(Term t) { Prop p0; PredEntry *pe; @@ -2805,15 +2692,15 @@ new_lu_entry(Term t) Functor f = FunctorOfTerm(t); FUNC_WRITE_LOCK(f); - p0 = Yap_NewPredPropByFunctor(f,IDB_MODULE); + p0 = Yap_NewPredPropByFunctor(f, IDB_MODULE); } else if (IsAtomTerm(t)) { Atom at = AtomOfTerm(t); WRITE_LOCK(RepAtom(at)->ARWLock); - p0 = Yap_NewPredPropByAtom(at,IDB_MODULE); + p0 = Yap_NewPredPropByAtom(at, IDB_MODULE); } else { FUNC_WRITE_LOCK(FunctorList); - p0 = Yap_NewPredPropByFunctor(FunctorList,IDB_MODULE); + p0 = Yap_NewPredPropByFunctor(FunctorList, IDB_MODULE); } pe = RepPredProp(p0); pe->PredFlags |= LogUpdatePredFlag; @@ -2826,9 +2713,7 @@ new_lu_entry(Term t) return pe; } -static DBProp -find_entry(Term t) -{ +static DBProp find_entry(Term t) { Atom at; UInt arity; @@ -2852,9 +2737,7 @@ find_entry(Term t) return RepDBProp(FindDBProp(RepAtom(at), 0, arity, 0)); } -static PredEntry * -find_lu_entry(Term t) -{ +static PredEntry *find_lu_entry(Term t) { Prop p; if (IsVarTerm(t)) { @@ -2870,11 +2753,11 @@ find_lu_entry(Term t) Yap_Error(TYPE_ERROR_KEY, t, "while accessing database key"); return NULL; } - p = Yap_GetPredPropByFuncInThisModule(FunctorOfTerm(t),IDB_MODULE); + p = Yap_GetPredPropByFuncInThisModule(FunctorOfTerm(t), IDB_MODULE); } else if (IsAtomTerm(t)) { - p = Yap_GetPredPropByAtomInThisModule(AtomOfTerm(t),IDB_MODULE); + p = Yap_GetPredPropByAtomInThisModule(AtomOfTerm(t), IDB_MODULE); } else { - p = Yap_GetPredPropByFuncInThisModule(FunctorList,IDB_MODULE); + p = Yap_GetPredPropByFuncInThisModule(FunctorList, IDB_MODULE); } if (p == NIL) { if (UPDATE_MODE == UPDATE_MODE_LOGICAL && !find_entry(t)) { @@ -2886,10 +2769,8 @@ find_lu_entry(Term t) return RepPredProp(p); } - -static DBProp -FetchIntDBPropFromKey(Int key, int flag, int new, char *error_mssg) -{ +static DBProp FetchIntDBPropFromKey(Int key, int flag, int new, + char *error_mssg) { Functor fun = (Functor)key; UInt hash_key = (CELL)key % INT_KEYS_SIZE; Prop p0; @@ -2898,7 +2779,7 @@ FetchIntDBPropFromKey(Int key, int flag, int new, char *error_mssg) init_int_keys(); if (INT_KEYS == NULL) { CACHE_REGS - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; LOCAL_Error_Term = TermNil; LOCAL_ErrorMessage = "could not allocate space"; return NULL; @@ -2915,8 +2796,8 @@ FetchIntDBPropFromKey(Int key, int flag, int new, char *error_mssg) if (new) { DBProp p; /* create a new DBProp */ - p = (DBProp) Yap_AllocAtomSpace(sizeof(*p)); - p->KindOfPE = DBProperty|flag; + p = (DBProp)Yap_AllocAtomSpace(sizeof(*p)); + p->KindOfPE = DBProperty | flag; p->F0 = p->L0 = NULL; p->ArityOfDB = 0; p->First = p->Last = NULL; @@ -2927,14 +2808,12 @@ FetchIntDBPropFromKey(Int key, int flag, int new, char *error_mssg) INT_KEYS[hash_key] = AbsDBProp(p); return p; } else { - return - RepDBProp(NULL); + return RepDBProp(NULL); } } -static DBProp -FetchDBPropFromKey(Term twork, int flag, int new, char *error_mssg) -{ +static DBProp FetchDBPropFromKey(Term twork, int flag, int new, + char *error_mssg) { Atom At; Int arity; Term dbmod; @@ -2945,46 +2824,40 @@ FetchDBPropFromKey(Term twork, int flag, int new, char *error_mssg) return RepDBProp(NULL); } if (!IsApplTerm(twork)) { - Yap_Error(SYSTEM_ERROR, twork, "missing module"); + Yap_Error(SYSTEM_ERROR_INTERNAL, twork, "missing module"); return RepDBProp(NULL); } else { Functor f = FunctorOfTerm(twork); if (f != FunctorModule) { - Yap_Error(SYSTEM_ERROR, twork, "missing module"); - return RepDBProp(NULL); + Yap_Error(SYSTEM_ERROR_INTERNAL, twork, "missing module"); + return RepDBProp(NULL); } dbmod = ArgOfTerm(1, twork); if (IsVarTerm(dbmod)) { - Yap_Error(INSTANTIATION_ERROR, twork, "var in module"); - return - RepDBProp(NIL); + Yap_Error(INSTANTIATION_ERROR, twork, "var in module"); + return RepDBProp(NIL); } if (!IsAtomTerm(dbmod)) { - Yap_Error(TYPE_ERROR_ATOM, twork, "not atom in module"); - return - RepDBProp(NIL); + Yap_Error(TYPE_ERROR_ATOM, twork, "not atom in module"); + return RepDBProp(NIL); } twork = ArgOfTerm(2, twork); } } else { dbmod = 0; - } if (IsVarTerm(twork)) { Yap_Error(INSTANTIATION_ERROR, twork, error_mssg); - return - RepDBProp(NIL); + return RepDBProp(NIL); } else if (IsAtomTerm(twork)) { arity = 0, At = AtomOfTerm(twork); } else if (IsIntegerTerm(twork)) { - return - FetchIntDBPropFromKey(IntegerOfTerm(twork), flag, new, error_mssg); + return FetchIntDBPropFromKey(IntegerOfTerm(twork), flag, new, error_mssg); } else if (IsApplTerm(twork)) { Register Functor f = FunctorOfTerm(twork); if (IsExtensionFunctor(f)) { Yap_Error(TYPE_ERROR_KEY, twork, error_mssg); - return - RepDBProp(NIL); + return RepDBProp(NIL); } At = NameOfFunctor(f); arity = ArityOfFunctor(f); @@ -2992,32 +2865,31 @@ FetchDBPropFromKey(Term twork, int flag, int new, char *error_mssg) At = AtomDot; arity = 2; } else { - Yap_Error(TYPE_ERROR_KEY, twork,error_mssg); - return - RepDBProp(NIL); + Yap_Error(TYPE_ERROR_KEY, twork, error_mssg); + return RepDBProp(NIL); } if (new) { DBProp p; AtomEntry *ae = RepAtom(At); WRITE_LOCK(ae->ARWLock); - if (EndOfPAEntr(p = RepDBProp(FindDBPropHavingLock(ae, flag, arity, dbmod)))) { - /* create a new DBProp */ + if (EndOfPAEntr( + p = RepDBProp(FindDBPropHavingLock(ae, flag, arity, dbmod)))) { + /* create a new DBProp */ int OLD_UPDATE_MODE = UPDATE_MODE; if (flag & MkCode) { - PredEntry *pp; - pp = RepPredProp(Yap_GetPredPropHavingLock(At, arity, dbmod)); - - if (!EndOfPAEntr(pp)) { - PELOCK(64,pp); - if(pp->PredFlags & LogUpdatePredFlag) - UPDATE_MODE = UPDATE_MODE_LOGICAL; - UNLOCK(pp->PELock); - } + PredEntry *pp; + pp = RepPredProp(Yap_GetPredPropHavingLock(At, arity, dbmod)); + if (!EndOfPAEntr(pp)) { + PELOCK(64, pp); + if (pp->PredFlags & LogUpdatePredFlag) + UPDATE_MODE = UPDATE_MODE_LOGICAL; + UNLOCK(pp->PELock); + } } - p = (DBProp) Yap_AllocAtomSpace(sizeof(*p)); - p->KindOfPE = DBProperty|flag; + p = (DBProp)Yap_AllocAtomSpace(sizeof(*p)); + p->KindOfPE = DBProperty | flag; p->F0 = p->L0 = NULL; UPDATE_MODE = OLD_UPDATE_MODE; p->ArityOfDB = arity; @@ -3026,23 +2898,18 @@ FetchDBPropFromKey(Term twork, int flag, int new, char *error_mssg) /* This is NOT standard but is QUITE convenient */ INIT_RWLOCK(p->DBRWLock); if (arity == 0) - p->FunctorOfDB = (Functor) At; + p->FunctorOfDB = (Functor)At; else - p->FunctorOfDB = Yap_UnlockedMkFunctor(ae,arity); + p->FunctorOfDB = Yap_UnlockedMkFunctor(ae, arity); AddPropToAtom(ae, (PropEntry *)p); } WRITE_UNLOCK(ae->ARWLock); - return - p; + return p; } else - return - RepDBProp(FindDBProp(RepAtom(At), flag, arity, dbmod)); + return RepDBProp(FindDBProp(RepAtom(At), flag, arity, dbmod)); } - -static Int -lu_nth_recorded(PredEntry *pe, Int Count USES_REGS) -{ +static Int lu_nth_recorded(PredEntry *pe, Int Count USES_REGS) { LogUpdClause *cl; XREGS[2] = MkVarTerm(); @@ -3050,30 +2917,26 @@ lu_nth_recorded(PredEntry *pe, Int Count USES_REGS) if (cl == NULL) return FALSE; #if MULTIPLE_STACKS - TRAIL_CLREF(cl); /* So that fail will erase it */ + TRAIL_CLREF(cl); /* So that fail will erase it */ INC_CLREF_COUNT(cl); #else if (!(cl->ClFlags & InUseMask)) { cl->ClFlags |= InUseMask; - TRAIL_CLREF(cl); /* So that fail will erase it */ + TRAIL_CLREF(cl); /* So that fail will erase it */ } #endif UNLOCK(pe->PELock); - return Yap_unify(MkDBRefTerm((DBRef)cl),ARG4); + return Yap_unify(MkDBRefTerm((DBRef)cl), ARG4); } - /* Finds a term recorded under the key ARG1 */ -static Int -nth_recorded(DBProp AtProp, Int Count USES_REGS) -{ - Register DBRef ref; +static Int nth_recorded(DBProp AtProp, Int Count USES_REGS) { + Register DBRef ref; READ_LOCK(AtProp->DBRWLock); ref = AtProp->First; Count--; - while (ref != NULL - && DEAD_REF(ref)) + while (ref != NULL && DEAD_REF(ref)) ref = NextDBRef(ref); if (ref == NULL) { READ_UNLOCK(AtProp->DBRWLock); @@ -3082,8 +2945,7 @@ nth_recorded(DBProp AtProp, Int Count USES_REGS) while (Count) { Count--; ref = NextDBRef(ref); - while (ref != NULL - && DEAD_REF(ref)) + while (ref != NULL && DEAD_REF(ref)) ref = NextDBRef(ref); if (ref == NULL) { READ_UNLOCK(AtProp->DBRWLock); @@ -3093,85 +2955,80 @@ nth_recorded(DBProp AtProp, Int Count USES_REGS) #if MULTIPLE_STACKS LOCK(ref->lock); READ_UNLOCK(AtProp->DBRWLock); - TRAIL_REF(ref); /* So that fail will erase it */ + TRAIL_REF(ref); /* So that fail will erase it */ INC_DBREF_COUNT(ref); UNLOCK(ref->lock); #else if (!(ref->Flags & InUseMask)) { ref->Flags |= InUseMask; - TRAIL_REF(ref); /* So that fail will erase it */ + TRAIL_REF(ref); /* So that fail will erase it */ } READ_UNLOCK(AtProp->DBRWLock); #endif - return Yap_unify(MkDBRefTerm(ref),ARG4); + return Yap_unify(MkDBRefTerm(ref), ARG4); } -Int -Yap_db_nth_recorded( PredEntry *pe, Int Count USES_REGS ) -{ - DBProp AtProp; +Int Yap_db_nth_recorded(PredEntry *pe, Int Count USES_REGS) { + DBProp AtProp; if (pe == NULL) { - return lu_nth_recorded(pe,Count PASS_REGS); + return lu_nth_recorded(pe, Count PASS_REGS); } - if (EndOfPAEntr(AtProp = FetchDBPropFromKey(Deref(ARG1), 0, FALSE, "nth_instance/3"))) { + if (EndOfPAEntr(AtProp = FetchDBPropFromKey(Deref(ARG1), 0, FALSE, + "nth_instance/3"))) { UNLOCK(pe->PELock); return FALSE; } return nth_recorded(AtProp, Count PASS_REGS); } -static Int -p_db_key( USES_REGS1 ) -{ - Register Term twork = Deref(ARG1); /* fetch the key */ - DBProp AtProp; +static Int p_db_key(USES_REGS1) { + Register Term twork = Deref(ARG1); /* fetch the key */ + DBProp AtProp; if (EndOfPAEntr(AtProp = FetchDBPropFromKey(twork, 0, TRUE, "db_key/3"))) { /* should never happen */ return FALSE; } - return Yap_unify(ARG2,MkIntegerTerm((Int)AtProp)); + return Yap_unify(ARG2, MkIntegerTerm((Int)AtProp)); } /* Finds a term recorded under the key ARG1 */ -static Int -i_recorded(DBProp AtProp, Term t3 USES_REGS) -{ - Term TermDB, TRef; - Register DBRef ref; +static Int i_recorded(DBProp AtProp, Term t3 USES_REGS) { + Term TermDB, TRef; + Register DBRef ref; Term twork; READ_LOCK(AtProp->DBRWLock); ref = AtProp->First; - while (ref != NULL - && DEAD_REF(ref)) + while (ref != NULL && DEAD_REF(ref)) ref = NextDBRef(ref); READ_UNLOCK(AtProp->DBRWLock); if (ref == NULL) { cut_fail(); } - twork = Deref(ARG2); /* now working with ARG2 */ + twork = Deref(ARG2); /* now working with ARG2 */ if (IsVarTerm(twork)) { - EXTRA_CBACK_ARG(3,2) = MkIntegerTerm(0); - EXTRA_CBACK_ARG(3,3) = MkIntegerTerm(0); + EXTRA_CBACK_ARG(3, 2) = MkIntegerTerm(0); + EXTRA_CBACK_ARG(3, 3) = MkIntegerTerm(0); B->cp_h = HR; while ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) == (CELL)0) { /* make sure the garbage collector sees what we want it to see! */ - EXTRA_CBACK_ARG(3,1) = (CELL)ref; + EXTRA_CBACK_ARG(3, 1) = (CELL)ref; /* oops, we are in trouble, not enough stack space */ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return FALSE; + } } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } } LOCAL_Error_Size = 0; twork = Deref(ARG2); @@ -3181,18 +3038,18 @@ i_recorded(DBProp AtProp, Term t3 USES_REGS) cut_fail(); } } else if (IsAtomOrIntTerm(twork)) { - EXTRA_CBACK_ARG(3,2) = MkIntegerTerm(0); - EXTRA_CBACK_ARG(3,3) = MkIntegerTerm((Int)twork); + EXTRA_CBACK_ARG(3, 2) = MkIntegerTerm(0); + EXTRA_CBACK_ARG(3, 3) = MkIntegerTerm((Int)twork); B->cp_h = HR; READ_LOCK(AtProp->DBRWLock); do { if (((twork == ref->DBT.Entry) || IsVarTerm(ref->DBT.Entry)) && - !DEAD_REF(ref)) - break; + !DEAD_REF(ref)) + break; ref = NextDBRef(ref); if (ref == NIL) { - READ_UNLOCK(AtProp->DBRWLock); - cut_fail(); + READ_UNLOCK(AtProp->DBRWLock); + cut_fail(); } } while (TRUE); READ_UNLOCK(AtProp->DBRWLock); @@ -3204,80 +3061,79 @@ i_recorded(DBProp AtProp, Term t3 USES_REGS) READ_LOCK(AtProp->DBRWLock); do { while ((mask & ref->Key) != (key & ref->Mask) && !DEAD_REF(ref)) { - ref = NextDBRef(ref); - if (ref == NULL) { - READ_UNLOCK(AtProp->DBRWLock); - cut_fail(); - } + ref = NextDBRef(ref); + if (ref == NULL) { + READ_UNLOCK(AtProp->DBRWLock); + cut_fail(); + } } if ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) != (CELL)0) { - if (Yap_unify(TermDB, ARG2)) { - /* success */ - EXTRA_CBACK_ARG(3,2) = MkIntegerTerm(((Int)mask)); - EXTRA_CBACK_ARG(3,3) = MkIntegerTerm(((Int)key)); - B->cp_h = HR; - break; - } else { - while ((ref = NextDBRef(ref)) != NULL - && DEAD_REF(ref)); - if (ref == NULL) { - READ_UNLOCK(AtProp->DBRWLock); - cut_fail(); - } - } + if (Yap_unify(TermDB, ARG2)) { + /* success */ + EXTRA_CBACK_ARG(3, 2) = MkIntegerTerm(((Int)mask)); + EXTRA_CBACK_ARG(3, 3) = MkIntegerTerm(((Int)key)); + B->cp_h = HR; + break; + } else { + while ((ref = NextDBRef(ref)) != NULL && DEAD_REF(ref)) + ; + if (ref == NULL) { + READ_UNLOCK(AtProp->DBRWLock); + cut_fail(); + } + } } else { - /* make sure the garbage collector sees what we want it to see! */ - EXTRA_CBACK_ARG(3,1) = (CELL)ref; - READ_UNLOCK(AtProp->DBRWLock); - EXTRA_CBACK_ARG(3,2) = MkIntegerTerm(((Int)mask)); - EXTRA_CBACK_ARG(3,3) = MkIntegerTerm(((Int)key)); - /* oops, we are in trouble, not enough stack space */ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } - } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } - } - READ_LOCK(AtProp->DBRWLock); + /* make sure the garbage collector sees what we want it to see! */ + EXTRA_CBACK_ARG(3, 1) = (CELL)ref; + READ_UNLOCK(AtProp->DBRWLock); + EXTRA_CBACK_ARG(3, 2) = MkIntegerTerm(((Int)mask)); + EXTRA_CBACK_ARG(3, 3) = MkIntegerTerm(((Int)key)); + /* oops, we are in trouble, not enough stack space */ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return FALSE; + } + } else { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } + } + READ_LOCK(AtProp->DBRWLock); } } while (TRUE); READ_UNLOCK(AtProp->DBRWLock); } - EXTRA_CBACK_ARG(3,1) = (CELL)ref; + EXTRA_CBACK_ARG(3, 1) = (CELL)ref; /* This should be after any non-tagged terms, because the routines in grow.c go from upper to lower addresses */ TRef = MkDBRefTerm(ref); #if MULTIPLE_STACKS LOCK(ref->lock); - TRAIL_REF(ref); /* So that fail will erase it */ + TRAIL_REF(ref); /* So that fail will erase it */ INC_DBREF_COUNT(ref); UNLOCK(ref->lock); #else if (!(ref->Flags & InUseMask)) { ref->Flags |= InUseMask; - TRAIL_REF(ref); /* So that fail will erase it */ + TRAIL_REF(ref); /* So that fail will erase it */ } #endif return (Yap_unify(ARG3, TRef)); } -static Int -c_recorded(int flags USES_REGS) -{ - Term TermDB, TRef; - Register DBRef ref, ref0; - CELL *PreviousHeap = HR; - CELL mask, key; +static Int c_recorded(int flags USES_REGS) { + Term TermDB, TRef; + Register DBRef ref, ref0; + CELL *PreviousHeap = HR; + CELL mask, key; Term t1; - t1 = EXTRA_CBACK_ARG(3,1); + t1 = EXTRA_CBACK_ARG(3, 1); ref0 = (DBRef)t1; READ_LOCK(ref0->Parent->DBRWLock); ref = NextDBRef(ref0); @@ -3285,71 +3141,69 @@ c_recorded(int flags USES_REGS) if (ref0->Flags & ErasedMask) { ref = ref0; while ((ref = ref->n) != NULL) { - if (!(ref->Flags & ErasedMask)) - break; + if (!(ref->Flags & ErasedMask)) + break; } /* we have used the DB entry, so we can remove it now, although - first we have to make sure noone is pointing to it */ + first we have to make sure noone is pointing to it */ if (ref == NULL) { - READ_UNLOCK(ref0->Parent->DBRWLock); - cut_fail(); + READ_UNLOCK(ref0->Parent->DBRWLock); + cut_fail(); } + } else { + READ_UNLOCK(ref0->Parent->DBRWLock); + cut_fail(); } - else - { - READ_UNLOCK(ref0->Parent->DBRWLock); - cut_fail(); - } } - + { - Term ttmp = EXTRA_CBACK_ARG(3,2); + Term ttmp = EXTRA_CBACK_ARG(3, 2); if (IsLongIntTerm(ttmp)) mask = (CELL)LongIntOfTerm(ttmp); else mask = (CELL)IntOfTerm(ttmp); } { - Term ttmp = EXTRA_CBACK_ARG(3,3); + Term ttmp = EXTRA_CBACK_ARG(3, 3); if (IsLongIntTerm(ttmp)) key = (CELL)LongIntOfTerm(ttmp); else key = (CELL)IntOfTerm(ttmp); } - while (ref != NIL - && DEAD_REF(ref)) + while (ref != NIL && DEAD_REF(ref)) ref = NextDBRef(ref); if (ref == NIL) { READ_UNLOCK(ref0->Parent->DBRWLock); cut_fail(); } - if (mask == 0 && key == 0) { /* ARG2 is a variable */ + if (mask == 0 && key == 0) { /* ARG2 is a variable */ while ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) == (CELL)0) { /* make sure the garbage collector sees what we want it to see! */ - EXTRA_CBACK_ARG(3,1) = (CELL)ref; + EXTRA_CBACK_ARG(3, 1) = (CELL)ref; /* oops, we are in trouble, not enough stack space */ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return FALSE; + } } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } } LOCAL_Error_Size = 0; PreviousHeap = HR; } Yap_unify(ARG2, TermDB); - } else if (mask == 0) { /* ARG2 is a constant */ + } else if (mask == 0) { /* ARG2 is a constant */ do { if (((key == Unsigned(ref->DBT.Entry)) || (ref->Flags & DBVar)) && - !DEAD_REF(ref)) - break; + !DEAD_REF(ref)) + break; ref = NextDBRef(ref); } while (ref != NIL); if (ref == NIL) { @@ -3357,57 +3211,58 @@ c_recorded(int flags USES_REGS) cut_fail(); } } else - do { /* ARG2 is a structure */ + do { /* ARG2 is a structure */ HR = PreviousHeap; while ((mask & ref->Key) != (key & ref->Mask)) { - while ((ref = NextDBRef(ref)) != NIL - && DEAD_REF(ref)); - if (ref == NIL) { - READ_UNLOCK(ref0->Parent->DBRWLock); - cut_fail(); - } + while ((ref = NextDBRef(ref)) != NIL && DEAD_REF(ref)) + ; + if (ref == NIL) { + READ_UNLOCK(ref0->Parent->DBRWLock); + cut_fail(); + } } while ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) == (CELL)0) { - /* make sure the garbage collector sees what we want it to see! */ - EXTRA_CBACK_ARG(3,1) = (CELL)ref; - /* oops, we are in trouble, not enough stack space */ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } - } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } - } - LOCAL_Error_Size = 0; - PreviousHeap = HR; + /* make sure the garbage collector sees what we want it to see! */ + EXTRA_CBACK_ARG(3, 1) = (CELL)ref; + /* oops, we are in trouble, not enough stack space */ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return FALSE; + } + } else { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, CP)) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } + } + LOCAL_Error_Size = 0; + PreviousHeap = HR; } if (Yap_unify(ARG2, TermDB)) - break; - while ((ref = NextDBRef(ref)) != NIL - && DEAD_REF(ref)); + break; + while ((ref = NextDBRef(ref)) != NIL && DEAD_REF(ref)) + ; if (ref == NIL) { - READ_UNLOCK(ref0->Parent->DBRWLock); - cut_fail(); + READ_UNLOCK(ref0->Parent->DBRWLock); + cut_fail(); } } while (1); READ_UNLOCK(ref0->Parent->DBRWLock); TRef = MkDBRefTerm(ref); - EXTRA_CBACK_ARG(3,1) = (CELL)ref; + EXTRA_CBACK_ARG(3, 1) = (CELL)ref; #if MULTIPLE_STACKS LOCK(ref->lock); - TRAIL_REF(ref); /* So that fail will erase it */ + TRAIL_REF(ref); /* So that fail will erase it */ INC_DBREF_COUNT(ref); UNLOCK(ref->lock); -#else +#else if (!(ref->Flags & InUseMask)) { ref->Flags |= InUseMask; - TRAIL_REF(ref); /* So that fail will erase it */ + TRAIL_REF(ref); /* So that fail will erase it */ } #endif return (Yap_unify(ARG3, TRef)); @@ -3415,15 +3270,14 @@ c_recorded(int flags USES_REGS) /* * The arguments for this 4 functions are the flags for terms which should be - * skipped + * skipped */ -static Int -lu_recorded(PredEntry *pe USES_REGS) { +static Int lu_recorded(PredEntry *pe USES_REGS) { op_numbers opc = Yap_op_from_opcode(P->opc); #if defined(YAPOR) || defined(THREADS) - PELOCK(66,pe); + PELOCK(66, pe); PP = pe; #endif if (opc == _procceed) { @@ -3433,7 +3287,7 @@ lu_recorded(PredEntry *pe USES_REGS) { CP = P; ENV = YENV; YENV = ASP; - YENV[E_CB] = (CELL) B; + YENV[E_CB] = (CELL)B; } P = pe->CodeOfPred; #if defined(YAPOR) || defined(THREADS) @@ -3453,21 +3307,17 @@ lu_recorded(PredEntry *pe USES_REGS) { } /* recorded(+Functor,+Term,-Ref) */ -static Int -in_rded_with_key( USES_REGS1 ) -{ +static Int in_rded_with_key(USES_REGS1) { DBProp AtProp = (DBProp)IntegerOfTerm(Deref(ARG1)); - return (i_recorded(AtProp,Deref(ARG3) PASS_REGS)); + return (i_recorded(AtProp, Deref(ARG3) PASS_REGS)); } /* recorded(+Functor,+Term,-Ref) */ -static Int -p_recorded( USES_REGS1 ) -{ - DBProp AtProp; - Register Term twork = Deref(ARG1); /* initially working with - * ARG1 */ +static Int p_recorded(USES_REGS1) { + DBProp AtProp; + Register Term twork = Deref(ARG1); /* initially working with + * ARG1 */ Term t3 = Deref(ARG3); PredEntry *pe; @@ -3479,7 +3329,8 @@ p_recorded( USES_REGS1 ) ref = DBRefOfTerm(t3); } ref = DBRefOfTerm(t3); - if (ref == NULL) return FALSE; + if (ref == NULL) + return FALSE; if (DEAD_REF(ref)) { return FALSE; } @@ -3489,44 +3340,44 @@ p_recorded( USES_REGS1 ) op_numbers opc = Yap_op_from_opcode(P->opc); if (!Yap_unify(GetDBLUKey(ap), ARG1)) - return FALSE; + return FALSE; if (opc == _procceed) { - P = cl->ClCode; + P = cl->ClCode; } else { - CP = P; + CP = P; #if defined(YAPOR) || defined(THREADS) - PP = cl->ClPred; + PP = cl->ClPred; #endif - P = cl->ClCode; - ENV = YENV; - YENV = ASP; - YENV[E_CB] = (CELL) B; + P = cl->ClCode; + ENV = YENV; + YENV = ASP; + YENV[E_CB] = (CELL)B; } return TRUE; } else { Term TermDB; while ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) == (CELL)0) { - /* oops, we are in trouble, not enough stack space */ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } - } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } - } + /* oops, we are in trouble, not enough stack space */ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return FALSE; + } + } else { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } + } } - if (!Yap_unify(ARG2,TermDB) - || !UnifyDBKey(ref,0,ARG1)) { - return FALSE; - } else { - return TRUE; + if (!Yap_unify(ARG2, TermDB) || !UnifyDBKey(ref, 0, ARG1)) { + return FALSE; + } else { + return TRUE; } } } @@ -3541,20 +3392,14 @@ p_recorded( USES_REGS1 ) return (i_recorded(AtProp, t3 PASS_REGS)); } -static Int -co_rded( USES_REGS1 ) -{ - return (c_recorded(0 PASS_REGS)); -} +static Int co_rded(USES_REGS1) { return (c_recorded(0 PASS_REGS)); } /* '$recordedp'(+Functor,+Term,-Ref) */ -static Int -in_rdedp( USES_REGS1 ) -{ - DBProp AtProp; - register choiceptr b0=B; - Register Term twork = Deref(ARG1); /* initially working with - * ARG1 */ +static Int in_rdedp(USES_REGS1) { + DBProp AtProp; + register choiceptr b0 = B; + Register Term twork = Deref(ARG1); /* initially working with + * ARG1 */ Term t3 = Deref(ARG3); if (!IsVarTerm(t3)) { @@ -3563,43 +3408,37 @@ in_rdedp( USES_REGS1 ) } else { DBRef ref = DBRefOfTerm(t3); LOCK(ref->lock); - if (ref == NULL - || DEAD_REF(ref) - || !Yap_unify(ARG2,GetDBTermFromDBEntry(ref PASS_REGS)) - || !UnifyDBKey(ref,CodeDBBit,ARG1)) { - UNLOCK(ref->lock); - cut_fail(); + if (ref == NULL || DEAD_REF(ref) || + !Yap_unify(ARG2, GetDBTermFromDBEntry(ref PASS_REGS)) || + !UnifyDBKey(ref, CodeDBBit, ARG1)) { + UNLOCK(ref->lock); + cut_fail(); } else { - UNLOCK(ref->lock); - cut_succeed(); + UNLOCK(ref->lock); + cut_succeed(); } } } - if (EndOfPAEntr(AtProp = FetchDBPropFromKey(twork, MkCode, FALSE, "recorded/3"))) { + if (EndOfPAEntr(AtProp = + FetchDBPropFromKey(twork, MkCode, FALSE, "recorded/3"))) { if (b0 == B) cut_fail(); else return FALSE; } - return (i_recorded(AtProp,t3 PASS_REGS)); + return (i_recorded(AtProp, t3 PASS_REGS)); } - -static Int -co_rdedp( USES_REGS1 ) -{ - return (c_recorded(MkCode PASS_REGS)); -} +static Int co_rdedp(USES_REGS1) { return (c_recorded(MkCode PASS_REGS)); } /* '$some_recordedp'(Functor) */ -static Int -p_somercdedp( USES_REGS1 ) -{ - Register DBRef ref; - DBProp AtProp; - Register Term twork = Deref(ARG1); /* initially working with - * ARG1 */ - if (EndOfPAEntr(AtProp = FetchDBPropFromKey(twork, MkCode, FALSE, "some_recorded/3"))) { +static Int p_somercdedp(USES_REGS1) { + Register DBRef ref; + DBProp AtProp; + Register Term twork = Deref(ARG1); /* initially working with + * ARG1 */ + if (EndOfPAEntr(AtProp = FetchDBPropFromKey(twork, MkCode, FALSE, + "some_recorded/3"))) { return FALSE; } READ_LOCK(AtProp->DBRWLock); @@ -3614,27 +3453,25 @@ p_somercdedp( USES_REGS1 ) } /* Finds the first instance recorded under key ARG1 */ -static Int -p_first_instance( USES_REGS1 ) -{ - Term TRef; - Register DBRef ref; - DBProp AtProp; - Register Term twork = Deref(ARG1); /* initially working with - * ARG1 */ +static Int p_first_instance(USES_REGS1) { + Term TRef; + Register DBRef ref; + DBProp AtProp; + Register Term twork = Deref(ARG1); /* initially working with + * ARG1 */ Term TermDB; ARG3 = Deref(ARG3); if (!IsVarTerm(ARG3)) { cut_fail(); } - if (EndOfPAEntr(AtProp = FetchDBPropFromKey(twork, 0, FALSE, "first_instance/3"))) { + if (EndOfPAEntr( + AtProp = FetchDBPropFromKey(twork, 0, FALSE, "first_instance/3"))) { return FALSE; } READ_LOCK(AtProp->DBRWLock); ref = AtProp->First; - while (ref != NIL - && (ref->Flags & (DBCode | ErasedMask))) + while (ref != NIL && (ref->Flags & (DBCode | ErasedMask))) ref = NextDBRef(ref); READ_UNLOCK(AtProp->DBRWLock); if (ref == NIL) { @@ -3644,28 +3481,29 @@ p_first_instance( USES_REGS1 ) /* we have a pointer to the term available */ LOCK(ref->lock); #if MULTIPLE_STACKS - TRAIL_REF(ref); /* So that fail will erase it */ + TRAIL_REF(ref); /* So that fail will erase it */ INC_DBREF_COUNT(ref); -#else +#else if (!(ref->Flags & InUseMask)) { ref->Flags |= InUseMask; - TRAIL_REF(ref); /* So that fail will erase it */ + TRAIL_REF(ref); /* So that fail will erase it */ } #endif UNLOCK(ref->lock); while ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) == (CELL)0) { /* oops, we are in trouble, not enough stack space */ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return FALSE; } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; + if (!Yap_gcl(LOCAL_Error_Size, 3, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; } } } @@ -3677,9 +3515,7 @@ p_first_instance( USES_REGS1 ) return Yap_unify(ARG3, TRef); } -static UInt -index_sz(LogUpdIndex *x) -{ +static UInt index_sz(LogUpdIndex *x) { UInt sz = x->ClSize; yamop *start = x->ClCode; op_numbers op = Yap_op_from_opcode(start->opc); @@ -3692,7 +3528,7 @@ index_sz(LogUpdIndex *x) if (op == _enter_lu_pred) { PredEntry *ap = x->ClPred; OPCODE endop, op1; - UInt count = 0, dead=0; + UInt count = 0, dead = 0; if (ap->PredFlags & CountPredFlag) endop = Yap_opcode(_count_trust_logical); @@ -3701,14 +3537,15 @@ index_sz(LogUpdIndex *x) else endop = Yap_opcode(_trust_logical); start = start->y_u.Illss.l1; - if (start->y_u.Illss.s) do { - sz += (UInt)NEXTOP((yamop*)NULL,OtaLl); - op1 = start->opc; - count++; - if (start->y_u.OtaLl.d->ClFlags & ErasedMask) - dead++; - start = start->y_u.OtaLl.n; - } while (op1 != endop); + if (start->y_u.Illss.s) + do { + sz += (UInt)NEXTOP((yamop *)NULL, OtaLl); + op1 = start->opc; + count++; + if (start->y_u.OtaLl.d->ClFlags & ErasedMask) + dead++; + start = start->y_u.OtaLl.n; + } while (op1 != endop); } x = x->ChildIndex; while (x != NULL) { @@ -3718,11 +3555,9 @@ index_sz(LogUpdIndex *x) return sz; } -static Int -lu_statistics(PredEntry *pe USES_REGS) -{ +static Int lu_statistics(PredEntry *pe USES_REGS) { UInt sz = sizeof(PredEntry), cls = 0, isz = 0; - + /* count number of clauses and size */ LogUpdClause *x; @@ -3743,18 +3578,18 @@ lu_statistics(PredEntry *pe USES_REGS) yamop *ep = ExpandClausesFirst; while (ep) { if (ep->y_u.sssllp.p == pe) - isz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->y_u.sssllp.s1*sizeof(yamop *); + isz += (UInt)NEXTOP((yamop *)NULL, sssllp) + + ep->y_u.sssllp.s1 * sizeof(yamop *); ep = ep->y_u.sssllp.snext; } isz += index_sz(ClauseCodeToLogUpdIndex(pe->cs.p_code.TrueCodeOfPred)); } - return - Yap_unify(ARG2,MkIntegerTerm(cls)) && - Yap_unify(ARG3,MkIntegerTerm(sz)) && - Yap_unify(ARG4,MkIntegerTerm(isz)); + return Yap_unify(ARG2, MkIntegerTerm(cls)) && + Yap_unify(ARG3, MkIntegerTerm(sz)) && + Yap_unify(ARG4, MkIntegerTerm(isz)); } -/** @pred key_statistics(+ _K_,- _Entries_,- _Size_,- _IndexSize_) +/** @pred key_statistics(+ _K_,- _Entries_,- _Size_,- _IndexSize_) Returns several statistics for a key _K_. Currently, it says how @@ -3762,13 +3597,11 @@ many entries we have for that key, _Entries_, what is the total size spent on entries, _Size_, and what is the amount of space spent in indices. - + */ -static Int -p_key_statistics( USES_REGS1 ) -{ +static Int p_key_statistics(USES_REGS1) { Register DBProp p; - Register DBRef x; + Register DBRef x; UInt sz = 0, cls = 0; Term twork = Deref(ARG1); PredEntry *pe; @@ -3784,22 +3617,18 @@ p_key_statistics( USES_REGS1 ) x = p->First; while (x != NULL) { cls++; - sz += sizeof(DBStruct)+sizeof(CELL)*x->DBT.NOfCells; + sz += sizeof(DBStruct) + sizeof(CELL) * x->DBT.NOfCells; if (x->Code) { DynamicClause *cl = ClauseCodeToDynamicClause(x->Code); - sz += cl->ClSize; + sz += cl->ClSize; } x = NextDBRef(x); } - return - Yap_unify(ARG2,MkIntegerTerm(cls)) && - Yap_unify(ARG3,MkIntegerTerm(sz)) && - Yap_unify(ARG4,MkIntTerm(0)); + return Yap_unify(ARG2, MkIntegerTerm(cls)) && + Yap_unify(ARG3, MkIntegerTerm(sz)) && Yap_unify(ARG4, MkIntTerm(0)); } -static Int -p_lu_statistics( USES_REGS1 ) -{ +static Int p_lu_statistics(USES_REGS1) { Term t = Deref(ARG1); Term mod = Deref(ARG5); PredEntry *pe; @@ -3811,7 +3640,7 @@ p_lu_statistics( USES_REGS1 ) } else if (IsIntegerTerm(t) && mod == IDB_MODULE) { pe = find_lu_int_key(IntegerOfTerm(t)); } else if (IsApplTerm(t)) { - Functor fun = FunctorOfTerm(t); + Functor fun = FunctorOfTerm(t); pe = RepPredProp(Yap_GetPredPropByFunc(fun, mod)); } else return FALSE; @@ -3824,10 +3653,7 @@ p_lu_statistics( USES_REGS1 ) return lu_statistics(pe PASS_REGS); } - -static Int -p_total_erased( USES_REGS1 ) -{ +static Int p_total_erased(USES_REGS1) { UInt sz = 0, cls = 0; UInt isz = 0, icls = 0; LogUpdClause *cl = DBErasedList; @@ -3844,16 +3670,13 @@ p_total_erased( USES_REGS1 ) isz += icl->ClSize; icl = icl->SiblingIndex; } - return - Yap_unify(ARG1,MkIntegerTerm(cls)) && - Yap_unify(ARG2,MkIntegerTerm(sz)) && - Yap_unify(ARG3,MkIntegerTerm(icls)) && - Yap_unify(ARG4,MkIntegerTerm(isz)); + return Yap_unify(ARG1, MkIntegerTerm(cls)) && + Yap_unify(ARG2, MkIntegerTerm(sz)) && + Yap_unify(ARG3, MkIntegerTerm(icls)) && + Yap_unify(ARG4, MkIntegerTerm(isz)); } -static Int -lu_erased_statistics(PredEntry *pe USES_REGS) -{ +static Int lu_erased_statistics(PredEntry *pe USES_REGS) { UInt sz = 0, cls = 0; UInt isz = 0, icls = 0; LogUpdClause *cl = DBErasedList; @@ -3873,100 +3696,86 @@ lu_erased_statistics(PredEntry *pe USES_REGS) } icl = icl->SiblingIndex; } - return - Yap_unify(ARG2,MkIntegerTerm(cls)) && - Yap_unify(ARG3,MkIntegerTerm(sz)) && - Yap_unify(ARG4,MkIntegerTerm(icls)) && - Yap_unify(ARG5,MkIntegerTerm(isz)); + return Yap_unify(ARG2, MkIntegerTerm(cls)) && + Yap_unify(ARG3, MkIntegerTerm(sz)) && + Yap_unify(ARG4, MkIntegerTerm(icls)) && + Yap_unify(ARG5, MkIntegerTerm(isz)); } -static Int -p_key_erased_statistics( USES_REGS1 ) -{ +static Int p_key_erased_statistics(USES_REGS1) { Term twork = Deref(ARG1); PredEntry *pe; /* only for log upds */ - if ((pe = find_lu_entry(twork)) == NULL) + if ((pe = find_lu_entry(twork)) == NULL) return FALSE; return lu_erased_statistics(pe PASS_REGS); } -static Int -p_heap_space_info( USES_REGS1 ) -{ - return - Yap_unify(ARG1,MkIntegerTerm(HeapUsed)) && - Yap_unify(ARG2,MkIntegerTerm(HeapMax-HeapUsed)) && - Yap_unify(ARG3,MkIntegerTerm(Yap_expand_clauses_sz)); +static Int p_heap_space_info(USES_REGS1) { + return Yap_unify(ARG1, MkIntegerTerm(HeapUsed)) && + Yap_unify(ARG2, MkIntegerTerm(HeapMax - HeapUsed)) && + Yap_unify(ARG3, MkIntegerTerm(Yap_expand_clauses_sz)); } - - /* * This is called when we are erasing a data base clause, because we may have - * pending references + * pending references */ -static void -ErasePendingRefs(DBTerm *entryref USES_REGS) -{ - DBRef *cp; - DBRef ref; +static void ErasePendingRefs(DBTerm *entryref USES_REGS) { + DBRef *cp; + DBRef ref; cp = entryref->DBRefs; if (entryref->DBRefs == NULL) return; while ((ref = *--cp) != NULL) { - if ((ref->Flags & DBClMask) && (--(ref->NOfRefsTo) == 0) - && (ref->Flags & ErasedMask)) + if ((ref->Flags & DBClMask) && (--(ref->NOfRefsTo) == 0) && + (ref->Flags & ErasedMask)) ErDBE(ref PASS_REGS); } } +inline static void RemoveDBEntry(DBRef entryref USES_REGS) { -inline static void -RemoveDBEntry(DBRef entryref USES_REGS) -{ - - ErasePendingRefs(&(entryref->DBT) PASS_REGS); + ErasePendingRefs(&(entryref->DBT)PASS_REGS); /* We may be backtracking back to a deleted entry. If we just remove the space then the info on the entry may be corrupt. */ - if ((B->cp_ap == RETRY_C_RECORDED_K_CODE - || B->cp_ap == RETRY_C_RECORDEDP_CODE) && - EXTRA_CBACK_ARG(3,1) == (CELL)entryref) { - /* make it clear the entry has been released */ + if ((B->cp_ap == RETRY_C_RECORDED_K_CODE || + B->cp_ap == RETRY_C_RECORDEDP_CODE) && + EXTRA_CBACK_ARG(3, 1) == (CELL)entryref) { +/* make it clear the entry has been released */ #if MULTIPLE_STACKS DEC_DBREF_COUNT(entryref); -#else +#else entryref->Flags &= ~InUseMask; #endif DBErasedMarker->Next = NULL; DBErasedMarker->Parent = entryref->Parent; DBErasedMarker->n = entryref->n; - EXTRA_CBACK_ARG(3,1) = (CELL)DBErasedMarker; + EXTRA_CBACK_ARG(3, 1) = (CELL)DBErasedMarker; } if (entryref->p != NULL) entryref->p->n = entryref->n; - else + else entryref->Parent->F0 = entryref->n; if (entryref->n != NULL) entryref->n->p = entryref->p; - else + else entryref->Parent->L0 = entryref->p; /* Yap_LUClauseSpace -= entryref->Size; */ - FreeDBSpace((char *) entryref); + FreeDBSpace((char *)entryref); } -static yamop * -find_next_clause(DBRef ref0 USES_REGS) -{ - Register DBRef ref; +static yamop *find_next_clause(DBRef ref0 USES_REGS) { + Register DBRef ref; yamop *newp; - /* fetch ref0 from the instruction we just started executing */ +/* fetch ref0 from the instruction we just started executing */ #ifdef DEBUG if (!(ref0->Flags & ErasedMask)) { - Yap_Error(SYSTEM_ERROR, TermNil, "find_next_clause (dead clause %x)", ref0); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, + "find_next_clause (dead clause %x)", ref0); return NULL; } #endif @@ -3984,8 +3793,8 @@ find_next_clause(DBRef ref0 USES_REGS) the choice-point, so that it believes we are actually working from that clause */ newp = ref->Code; - /* and next let's tell the world this clause is being used, just - like if we were executing a standard retry_and_mark */ +/* and next let's tell the world this clause is being used, just + like if we were executing a standard retry_and_mark */ #if MULTIPLE_STACKS { DynamicClause *cl = ClauseCodeToDynamicClause(newp); @@ -3995,7 +3804,7 @@ find_next_clause(DBRef ref0 USES_REGS) INC_CLREF_COUNT(cl); UNLOCK(cl->ClLock); } -#else +#else if (!(DynamicFlags(newp) & InUseMask)) { DynamicFlags(newp) |= InUseMask; TRAIL_CLREF(ClauseCodeToDynamicClause(newp)); @@ -4007,31 +3816,29 @@ find_next_clause(DBRef ref0 USES_REGS) /* This procedure is called when a clause is officialy deleted. Its job is to find out where the code can go next, if it can go anywhere */ -static Int -p_jump_to_next_dynamic_clause( USES_REGS1 ) -{ - DBRef ref = (DBRef)(((yamop *)((CODEADDR)P-(CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.bmap); +static Int p_jump_to_next_dynamic_clause(USES_REGS1) { + DBRef ref = + (DBRef)(((yamop *)((CODEADDR)P - (CELL)NEXTOP((yamop *)NULL, Osbpp))) + ->y_u.Osbpp.bmap); yamop *newp = find_next_clause(ref PASS_REGS); - + if (newp == NULL) { cut_fail(); } /* the next alternative to try must be obtained from this clause */ B->cp_ap = newp; /* and next, enter the clause */ - P = NEXTOP(newp,Otapl); + P = NEXTOP(newp, Otapl); /* and return like if nothing had happened. */ return TRUE; } -static void -complete_lu_erase(LogUpdClause *clau) -{ +static void complete_lu_erase(LogUpdClause *clau) { DBRef *cp; if (clau->ClFlags & FactMask) cp = NULL; - else + else cp = clau->lusl.ClSource->DBRefs; if (CL_IN_USE(clau)) { return; @@ -4049,25 +3856,23 @@ complete_lu_erase(LogUpdClause *clau) DBRef ref; while ((ref = *--cp) != NIL) { if (ref->Flags & LogUpdMask) { - LogUpdClause *cl = (LogUpdClause *)ref; - cl->ClRefCount--; - if (cl->ClFlags & ErasedMask && - !(cl->ClFlags & InUseMask) && - !(cl->ClRefCount)) { - EraseLogUpdCl(cl); - } + LogUpdClause *cl = (LogUpdClause *)ref; + cl->ClRefCount--; + if (cl->ClFlags & ErasedMask && !(cl->ClFlags & InUseMask) && + !(cl->ClRefCount)) { + EraseLogUpdCl(cl); + } } else { - LOCK(ref->lock); - ref->NOfRefsTo--; - if (ref->Flags & ErasedMask && - !(ref->Flags & InUseMask) && - ref->NOfRefsTo) { - CACHE_REGS - UNLOCK(ref->lock); - ErDBE(ref PASS_REGS); - } else { - UNLOCK(ref->lock); - } + LOCK(ref->lock); + ref->NOfRefsTo--; + if (ref->Flags & ErasedMask && !(ref->Flags & InUseMask) && + ref->NOfRefsTo) { + CACHE_REGS + UNLOCK(ref->lock); + ErDBE(ref PASS_REGS); + } else { + UNLOCK(ref->lock); + } } } } @@ -4076,13 +3881,11 @@ complete_lu_erase(LogUpdClause *clau) Yap_FreeCodeSpace((char *)clau); } -static void -EraseLogUpdCl(LogUpdClause *clau) -{ +static void EraseLogUpdCl(LogUpdClause *clau) { PredEntry *ap; ap = clau->ClPred; - /* no need to erase what has been erased */ + /* no need to erase what has been erased */ if (!(clau->ClFlags & ErasedMask)) { /* get ourselves out of the list */ if (clau->ClNext != NULL) { @@ -4093,18 +3896,18 @@ EraseLogUpdCl(LogUpdClause *clau) } if (ap) { if (clau->ClCode == ap->cs.p_code.FirstClause) { - if (clau->ClNext == NULL) { - ap->cs.p_code.FirstClause = NULL; - } else { - ap->cs.p_code.FirstClause = clau->ClNext->ClCode; - } + if (clau->ClNext == NULL) { + ap->cs.p_code.FirstClause = NULL; + } else { + ap->cs.p_code.FirstClause = clau->ClNext->ClCode; + } } if (clau->ClCode == ap->cs.p_code.LastClause) { - if (clau->ClPrev == NULL) { - ap->cs.p_code.LastClause = NULL; - } else { - ap->cs.p_code.LastClause = clau->ClPrev->ClCode; - } + if (clau->ClPrev == NULL) { + ap->cs.p_code.LastClause = NULL; + } else { + ap->cs.p_code.LastClause = clau->ClPrev->ClCode; + } } ap->cs.p_code.NOfClauses--; } @@ -4113,11 +3916,11 @@ EraseLogUpdCl(LogUpdClause *clau) { LogUpdClause *er_head = DBErasedList; if (er_head == NULL) { - clau->ClPrev = clau->ClNext = NULL; + clau->ClPrev = clau->ClNext = NULL; } else { - clau->ClNext = er_head; - er_head->ClPrev = clau; - clau->ClPrev = NULL; + clau->ClNext = er_head; + er_head->ClPrev = clau; + clau->ClPrev = NULL; } DBErasedList = clau; } @@ -4127,23 +3930,25 @@ EraseLogUpdCl(LogUpdClause *clau) if (ap) { /* mark it as erased */ if (ap->LastCallOfPred != LUCALL_RETRACT) { - if (ap->cs.p_code.NOfClauses > 1) { - if (ap->TimeStampOfPred >= TIMESTAMP_RESET) - Yap_UpdateTimestamps(ap); - ++ap->TimeStampOfPred; - /* fprintf(stderr,"- %x--%d--%ul\n",ap,ap->TimeStampOfPred,ap->ArityOfPE);*/ - ap->LastCallOfPred = LUCALL_RETRACT; - } else { - /* OK, there's noone left */ + if (ap->cs.p_code.NOfClauses > 1) { + if (ap->TimeStampOfPred >= TIMESTAMP_RESET) + Yap_UpdateTimestamps(ap); + ++ap->TimeStampOfPred; + /* fprintf(stderr,"- + * %x--%d--%ul\n",ap,ap->TimeStampOfPred,ap->ArityOfPE);*/ + ap->LastCallOfPred = LUCALL_RETRACT; + } else { +/* OK, there's noone left */ #ifndef THREADS - if (ap->cs.p_code.NOfClauses == 0) { - /* Other threads may hold refs to clauses */ - ap->TimeStampOfPred = 0L; - } + if (ap->cs.p_code.NOfClauses == 0) { + /* Other threads may hold refs to clauses */ + ap->TimeStampOfPred = 0L; + } #endif - /* fprintf(stderr,"- %x--%d--%ul\n",ap,ap->TimeStampOfPred,ap->ArityOfPE);*/ - ap->LastCallOfPred = LUCALL_ASSERT; - } + /* fprintf(stderr,"- + * %x--%d--%ul\n",ap,ap->TimeStampOfPred,ap->ArityOfPE);*/ + ap->LastCallOfPred = LUCALL_ASSERT; + } } clau->ClTimeEnd = ap->TimeStampOfPred; Yap_RemoveClauseFromIndex(ap, clau->ClCode); @@ -4154,25 +3959,24 @@ EraseLogUpdCl(LogUpdClause *clau) complete_lu_erase(clau); } -static void -MyEraseClause(DynamicClause *clau USES_REGS) -{ - DBRef ref; +static void MyEraseClause(DynamicClause *clau USES_REGS) { + DBRef ref; if (CL_IN_USE(clau)) return; /* - I don't need to lock the clause at this point because + I don't need to lock the clause at this point because I am the last one using it anyway. */ - ref = (DBRef) NEXTOP(clau->ClCode,Otapl)->y_u.Osbpp.bmap; + ref = (DBRef)NEXTOP(clau->ClCode, Otapl)->y_u.Osbpp.bmap; /* don't do nothing if the reference is still in use */ if (DBREF_IN_USE(ref)) return; - if ( P == clau->ClCode ) { + if (P == clau->ClCode) { yamop *np = RTRYCODE; /* make it the next alternative */ - np->y_u.Otapl.d = find_next_clause((DBRef)(NEXTOP(P,Otapl)->y_u.Osbpp.bmap) PASS_REGS); + np->y_u.Otapl.d = + find_next_clause((DBRef)(NEXTOP(P, Otapl)->y_u.Osbpp.bmap)PASS_REGS); if (np->y_u.Otapl.d == NULL) P = (yamop *)FAILCODE; else { @@ -4198,27 +4002,19 @@ MyEraseClause(DynamicClause *clau USES_REGS) This predicate is supposed to be called with a lock on the current predicate */ -void -Yap_ErLogUpdCl(LogUpdClause *clau) -{ - EraseLogUpdCl(clau); -} +void Yap_ErLogUpdCl(LogUpdClause *clau) { EraseLogUpdCl(clau); } /* This predicate is supposed to be called with a lock on the current predicate */ -void -Yap_ErCl(DynamicClause *clau) -{ +void Yap_ErCl(DynamicClause *clau) { CACHE_REGS MyEraseClause(clau PASS_REGS); } -static void -PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr) -{ - yamop *code_p = clau->ClCode; +static void PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr) { + yamop *code_p = clau->ClCode; PredEntry *p = clau->ClPred; yamop *cl = code_p; @@ -4229,7 +4025,7 @@ PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr) if (p->cs.p_code.FirstClause != cl) { /* we are not the first clause... */ yamop *prev_code_p = (yamop *)(dbr->Prev->Code); - prev_code_p->y_u.Otapl.d = code_p->y_u.Otapl.d; + prev_code_p->y_u.Otapl.d = code_p->y_u.Otapl.d; /* are we the last? */ if (p->cs.p_code.LastClause == cl) p->cs.p_code.LastClause = prev_code_p; @@ -4239,11 +4035,10 @@ PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr) p->cs.p_code.LastClause = p->cs.p_code.FirstClause = NULL; } else { p->cs.p_code.FirstClause = code_p->y_u.Otapl.d; - p->cs.p_code.FirstClause->opc = - Yap_opcode(_try_me); + p->cs.p_code.FirstClause->opc = Yap_opcode(_try_me); } } - dbr->Code = NULL; /* unlink the two now */ + dbr->Code = NULL; /* unlink the two now */ if (p->PredFlags & IndexedPredFlag) { p->cs.p_code.NOfClauses--; Yap_RemoveIndexation(p); @@ -4255,107 +4050,98 @@ PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr) code_p = p->cs.p_code.FirstClause; code_p->y_u.Otapl.d = p->cs.p_code.FirstClause; p->cs.p_code.TrueCodeOfPred = NEXTOP(code_p, Otapl); - if (p->PredFlags & (SpiedPredFlag|CountPredFlag|ProfiledPredFlag)) { - p->OpcodeOfPred = Yap_opcode(_spy_pred); - p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + if (p->PredFlags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag)) { + p->OpcodeOfPred = Yap_opcode(_spy_pred); + p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); #if defined(YAPOR) || defined(THREADS) } else if (p->ModuleOfPred != IDB_MODULE && - !(p->PredFlags & ThreadLocalPredFlag)) { - p->OpcodeOfPred = LOCKPRED_OPCODE; - p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + !(p->PredFlags & ThreadLocalPredFlag)) { + p->OpcodeOfPred = LOCKPRED_OPCODE; + p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); #endif } else { - p->CodeOfPred = p->cs.p_code.TrueCodeOfPred; - p->OpcodeOfPred = p->cs.p_code.TrueCodeOfPred->opc; + p->CodeOfPred = p->cs.p_code.TrueCodeOfPred; + p->OpcodeOfPred = p->cs.p_code.TrueCodeOfPred->opc; } #if defined(YAPOR) || defined(THREADS) } else if (p->ModuleOfPred != IDB_MODULE && - !(p->PredFlags & ThreadLocalPredFlag)) { - p->OpcodeOfPred = LOCKPRED_OPCODE; - p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + !(p->PredFlags & ThreadLocalPredFlag)) { + p->OpcodeOfPred = LOCKPRED_OPCODE; + p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); #endif } else { p->OpcodeOfPred = FAIL_OPCODE; - p->cs.p_code.TrueCodeOfPred = p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + p->cs.p_code.TrueCodeOfPred = p->CodeOfPred = + (yamop *)(&(p->OpcodeOfPred)); } } else { - if (p->PredFlags & (SpiedPredFlag|CountPredFlag|ProfiledPredFlag)) { + if (p->PredFlags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag)) { p->OpcodeOfPred = Yap_opcode(_spy_pred); - p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); #if defined(YAPOR) || defined(THREADS) } else if (p->ModuleOfPred != IDB_MODULE && - !(p->PredFlags & ThreadLocalPredFlag)) { + !(p->PredFlags & ThreadLocalPredFlag)) { p->OpcodeOfPred = LOCKPRED_OPCODE; p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); #endif } else { p->OpcodeOfPred = INDEX_OPCODE; - p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); + p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); } } } -static void -PrepareToEraseClause(DynamicClause *clau, DBRef dbr) -{ -} +static void PrepareToEraseClause(DynamicClause *clau, DBRef dbr) {} -static void -ErDBE(DBRef entryref USES_REGS) -{ +static void ErDBE(DBRef entryref USES_REGS) { if ((entryref->Flags & DBCode) && entryref->Code) { if (entryref->Flags & LogUpdMask) { LogUpdClause *clau = ClauseCodeToLogUpdClause(entryref->Code); if (CL_IN_USE(clau) || entryref->NOfRefsTo != 0) { - PrepareToEraseLogUpdClause(clau, entryref); + PrepareToEraseLogUpdClause(clau, entryref); } else { - if (!(clau->ClFlags & ErasedMask)) - PrepareToEraseLogUpdClause(clau, entryref); - /* the clause must have left the chain */ - EraseLogUpdCl(clau); + if (!(clau->ClFlags & ErasedMask)) + PrepareToEraseLogUpdClause(clau, entryref); + /* the clause must have left the chain */ + EraseLogUpdCl(clau); } } else { DynamicClause *clau = ClauseCodeToDynamicClause(entryref->Code); if (CL_IN_USE(clau) || entryref->NOfRefsTo != 0) { - PrepareToEraseClause(clau, entryref); + PrepareToEraseClause(clau, entryref); } else { - if (!(clau->ClFlags & ErasedMask)) - PrepareToEraseClause(clau, entryref); - /* the clause must have left the chain */ - MyEraseClause(clau PASS_REGS); + if (!(clau->ClFlags & ErasedMask)) + PrepareToEraseClause(clau, entryref); + /* the clause must have left the chain */ + MyEraseClause(clau PASS_REGS); } } } else if (!(DBREF_IN_USE(entryref))) { - if (entryref->NOfRefsTo == 0) + if (entryref->NOfRefsTo == 0) RemoveDBEntry(entryref PASS_REGS); else if (!(entryref->Flags & ErasedMask)) { /* oops, I cannot remove it, but I at least have to tell - the world what's going on */ + the world what's going on */ entryref->Flags |= ErasedMask; entryref->Next = entryref->Prev = NIL; } } } -void -Yap_ErDBE(DBRef entryref) -{ +void Yap_ErDBE(DBRef entryref) { CACHE_REGS ErDBE(entryref PASS_REGS); } -static void -EraseEntry(DBRef entryref) -{ - DBProp p; +static void EraseEntry(DBRef entryref) { + DBProp p; if (entryref->Flags & ErasedMask) return; - if (entryref->Flags & LogUpdMask && - !(entryref->Flags & DBClMask)) { + if (entryref->Flags & LogUpdMask && !(entryref->Flags & DBClMask)) { LogUpdClause *luclause = (LogUpdClause *)entryref; - PELOCK(67,luclause->ClPred); + PELOCK(67, luclause->ClPred); EraseLogUpdCl(luclause); UNLOCK(luclause->ClPred->PELock); return; @@ -4384,9 +4170,7 @@ EraseEntry(DBRef entryref) } /* erase(+Ref) */ -static Int -p_erase( USES_REGS1 ) -{ +static Int p_erase(USES_REGS1) { Term t1 = Deref(ARG1); if (IsVarTerm(t1)) { @@ -4402,9 +4186,7 @@ p_erase( USES_REGS1 ) } /* increase_reference_counter(+Ref) */ -static Int -p_increase_reference_counter( USES_REGS1 ) -{ +static Int p_increase_reference_counter(USES_REGS1) { Term t1 = Deref(ARG1); LogUpdClause *cl; @@ -4417,16 +4199,14 @@ p_increase_reference_counter( USES_REGS1 ) return FALSE; } cl = (LogUpdClause *)DBRefOfTerm(t1); - PELOCK(67,cl->ClPred); + PELOCK(67, cl->ClPred); cl->ClRefCount++; UNLOCK(cl->ClPred->PELock); return TRUE; } /* increase_reference_counter(+Ref) */ -static Int -p_decrease_reference_counter( USES_REGS1 ) -{ +static Int p_decrease_reference_counter(USES_REGS1) { Term t1 = Deref(ARG1); LogUpdClause *cl; @@ -4439,7 +4219,7 @@ p_decrease_reference_counter( USES_REGS1 ) return FALSE; } cl = (LogUpdClause *)DBRefOfTerm(t1); - PELOCK(67,cl->ClPred); + PELOCK(67, cl->ClPred); if (cl->ClRefCount) { cl->ClRefCount--; UNLOCK(cl->ClPred->PELock); @@ -4450,17 +4230,15 @@ p_decrease_reference_counter( USES_REGS1 ) } /* erase(+Ref) */ -/** @pred erase(+ _R_) +/** @pred erase(+ _R_) The term referred to by _R_ is erased from the internal database. If reference _R_ does not exist in the database, `erase` just fails. - + */ -static Int -p_current_reference_counter( USES_REGS1 ) -{ +static Int p_current_reference_counter(USES_REGS1) { Term t1 = Deref(ARG1); LogUpdClause *cl; @@ -4476,9 +4254,7 @@ p_current_reference_counter( USES_REGS1 ) return Yap_unify(ARG2, MkIntegerTerm(cl->ClRefCount)); } -static Int -p_erase_clause( USES_REGS1 ) -{ +static Int p_erase_clause(USES_REGS1) { Term t1 = Deref(ARG1); DBRef entryref; @@ -4489,16 +4265,19 @@ p_erase_clause( USES_REGS1 ) if (!IsDBRefTerm(t1)) { if (IsApplTerm(t1)) { if (FunctorOfTerm(t1) == FunctorStaticClause) { - Yap_EraseStaticClause(Yap_ClauseFromTerm(t1), (PredEntry *)IntegerOfTerm(ArgOfTerm(2,t1)), Deref(ARG2)); - return TRUE; + Yap_EraseStaticClause(Yap_ClauseFromTerm(t1), + (PredEntry *)IntegerOfTerm(ArgOfTerm(2, t1)), + Deref(ARG2)); + return TRUE; } if (FunctorOfTerm(t1) == FunctorMegaClause) { - Yap_EraseMegaClause(Yap_MegaClauseFromTerm(t1), Yap_MegaClausePredicateFromTerm(t1)); - return TRUE; + Yap_EraseMegaClause(Yap_MegaClauseFromTerm(t1), + Yap_MegaClausePredicateFromTerm(t1)); + return TRUE; } if (FunctorOfTerm(t1) == FunctorExoClause) { - Yap_Error(TYPE_ERROR_DBREF, t1, "erase exo clause"); - return FALSE; + Yap_Error(TYPE_ERROR_DBREF, t1, "erase exo clause"); + return FALSE; } } Yap_Error(TYPE_ERROR_DBREF, t1, "erase"); @@ -4509,20 +4288,18 @@ p_erase_clause( USES_REGS1 ) EraseEntry(entryref); return TRUE; } - + /* eraseall(+Key) */ -/** @pred eraseall(+ _K_) +/** @pred eraseall(+ _K_) All terms belonging to the key `K` are erased from the internal database. The predicate always succeeds. - + */ -static Int -p_eraseall( USES_REGS1 ) -{ - Register Term twork = Deref(ARG1); - Register DBRef entryref; - DBProp p; +static Int p_eraseall(USES_REGS1) { + Register Term twork = Deref(ARG1); + Register DBRef entryref; + DBProp p; PredEntry *pe; if ((pe = find_lu_entry(twork)) != NULL) { @@ -4548,8 +4325,7 @@ p_eraseall( USES_REGS1 ) do { DBRef next_entryref; - while (entryref != NIL && - (entryref->Flags & (DBCode | ErasedMask))) + while (entryref != NIL && (entryref->Flags & (DBCode | ErasedMask))) entryref = NextDBRef(entryref); if (entryref == NIL) break; @@ -4577,20 +4353,17 @@ p_eraseall( USES_REGS1 ) return (TRUE); } - /* erased(+Ref) */ -/** @pred erased(+ _R_) +/** @pred erased(+ _R_) Succeeds if the object whose database reference is _R_ has been erased. - + */ -static Int -p_erased( USES_REGS1 ) -{ - Term t = Deref(ARG1); +static Int p_erased(USES_REGS1) { + Term t = Deref(ARG1); if (IsVarTerm(t)) { Yap_Error(INSTANTIATION_ERROR, t, "erased"); @@ -4603,15 +4376,13 @@ p_erased( USES_REGS1 ) return (DBRefOfTerm(t)->Flags & ErasedMask); } -static Int -static_instance(StaticClause *cl, PredEntry *ap USES_REGS) -{ +static Int static_instance(StaticClause *cl, PredEntry *ap USES_REGS) { if (cl->ClFlags & ErasedMask) { return FALSE; } if (cl->ClFlags & FactMask) { if (ap->ArityOfPE == 0) { - return Yap_unify(ARG2,MkAtomTerm((Atom)ap->FunctorOfPred)); + return Yap_unify(ARG2, MkAtomTerm((Atom)ap->FunctorOfPred)); } else { Functor f = ap->FunctorOfPred; UInt arity = ArityOfFunctor(ap->FunctorOfPred), i; @@ -4619,17 +4390,17 @@ static_instance(StaticClause *cl, PredEntry *ap USES_REGS) CELL *ptr; if (IsVarTerm(t2)) { - Yap_unify(ARG2, (t2 = Yap_MkNewApplTerm(f,arity))); + Yap_unify(ARG2, (t2 = Yap_MkNewApplTerm(f, arity))); } else if (!IsApplTerm(t2) || FunctorOfTerm(t2) != f) { - return FALSE; + return FALSE; } - ptr = RepAppl(t2)+1; - for (i=0; iClCode; return TRUE; } @@ -4638,59 +4409,57 @@ static_instance(StaticClause *cl, PredEntry *ap USES_REGS) while ((TermDB = GetDBTerm(cl->usc.ClSource, TRUE PASS_REGS)) == 0L) { /* oops, we are in trouble, not enough stack space */ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return FALSE; + } } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } } } return Yap_unify(ARG2, TermDB); } } -static Int -exo_instance(Int i, PredEntry *ap USES_REGS) -{ +static Int exo_instance(Int i, PredEntry *ap USES_REGS) { if (ap->ArityOfPE == 0) { - return Yap_unify(ARG2,MkAtomTerm((Atom)ap->FunctorOfPred)); + return Yap_unify(ARG2, MkAtomTerm((Atom)ap->FunctorOfPred)); } else { MegaClause *mcl = ClauseCodeToMegaClause(ap->cs.p_code.FirstClause); Functor f = ap->FunctorOfPred; UInt arity = ArityOfFunctor(ap->FunctorOfPred); Term t2 = Deref(ARG2); - CELL *ptr = (CELL *)((ADDR)mcl->ClCode+2*sizeof(struct index_t *)+i*(mcl->ClItemSize)); + CELL *ptr = (CELL *)((ADDR)mcl->ClCode + 2 * sizeof(struct index_t *) + + i * (mcl->ClItemSize)); if (IsVarTerm(t2)) { // fresh slate - t2 = Yap_MkApplTerm(f,arity,ptr); + t2 = Yap_MkApplTerm(f, arity, ptr); Yap_unify(ARG2, t2); } else if (!IsApplTerm(t2) || FunctorOfTerm(t2) != f) { return FALSE; } - for (i=0; iClCode; return TRUE; } } -static Int -mega_instance(yamop *code, PredEntry *ap USES_REGS) -{ +static Int mega_instance(yamop *code, PredEntry *ap USES_REGS) { if (ap->ArityOfPE == 0) { - return Yap_unify(ARG2,MkAtomTerm((Atom)ap->FunctorOfPred)); + return Yap_unify(ARG2, MkAtomTerm((Atom)ap->FunctorOfPred)); } else { Functor f = ap->FunctorOfPred; UInt arity = ArityOfFunctor(ap->FunctorOfPred), i; @@ -4698,25 +4467,25 @@ mega_instance(yamop *code, PredEntry *ap USES_REGS) CELL *ptr; if (IsVarTerm(t2)) { - t2 = Yap_MkNewApplTerm(f,arity); + t2 = Yap_MkNewApplTerm(f, arity); Yap_unify(ARG2, t2); } else if (!IsApplTerm(t2) || FunctorOfTerm(t2) != f) { return FALSE; } - ptr = RepAppl(t2)+1; - for (i=0; iClPred; - PELOCK(68,ap); + PELOCK(68, ap); if (cl->ClFlags & ErasedMask) { UNLOCK(ap->PELock); return FALSE; } if (cl->ClFlags & FactMask) { if (ap->ArityOfPE == 0) { - UNLOCK(ap->PELock); - return Yap_unify(ARG2,MkAtomTerm((Atom)ap->FunctorOfPred)); + UNLOCK(ap->PELock); + return Yap_unify(ARG2, MkAtomTerm((Atom)ap->FunctorOfPred)); } else { - Functor f = ap->FunctorOfPred; - UInt arity = ArityOfFunctor(ap->FunctorOfPred), i; - Term t2 = Deref(ARG2); - CELL *ptr; + Functor f = ap->FunctorOfPred; + UInt arity = ArityOfFunctor(ap->FunctorOfPred), i; + Term t2 = Deref(ARG2); + CELL *ptr; - if (IsVarTerm(t2)) { - Yap_unify(ARG2, (t2 = Yap_MkNewApplTerm(f,arity))); - } else if (!IsApplTerm(t2) || FunctorOfTerm(t2) != f) { - UNLOCK(ap->PELock); - return FALSE; - } - ptr = RepAppl(t2)+1; - for (i=0; iClCode; + if (IsVarTerm(t2)) { + Yap_unify(ARG2, (t2 = Yap_MkNewApplTerm(f, arity))); + } else if (!IsApplTerm(t2) || FunctorOfTerm(t2) != f) { + UNLOCK(ap->PELock); + return FALSE; + } + ptr = RepAppl(t2) + 1; + for (i = 0; i < arity; i++) { + XREGS[i + 1] = ptr[i]; + } + CP = P; + YENV = ASP; + YENV[E_CB] = (CELL)B; + P = cl->ClCode; #if defined(YAPOR) || defined(THREADS) - if (ap->PredFlags & ThreadLocalPredFlag) { - UNLOCK(ap->PELock); - } else { - PP = ap; - } + if (ap->PredFlags & ThreadLocalPredFlag) { + UNLOCK(ap->PELock); + } else { + PP = ap; + } #endif - return TRUE; + return TRUE; } } opc = Yap_op_from_opcode(cl->ClCode->opc); if (opc == _unify_idb_term) { UNLOCK(ap->PELock); return Yap_unify(ARG2, cl->lusl.ClSource->Entry); - } else { - Term TermDB; + } else { + Term TermDB; int in_cl = (opc != _copy_idb_term); while ((TermDB = GetDBTerm(cl->lusl.ClSource, in_cl PASS_REGS)) == 0L) { - /* oops, we are in trouble, not enough stack space */ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - UNLOCK(ap->PELock); - return FALSE; - } - } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - UNLOCK(ap->PELock); - return FALSE; - } - } + /* oops, we are in trouble, not enough stack space */ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + UNLOCK(ap->PELock); + return FALSE; + } + } else { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + UNLOCK(ap->PELock); + return FALSE; + } + } } UNLOCK(ap->PELock); return Yap_unify(ARG2, TermDB); } } else { - Term TermDB; + Term TermDB; while ((TermDB = GetDBTermFromDBEntry(dbr PASS_REGS)) == 0L) { /* oops, we are in trouble, not enough stack space */ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return FALSE; + } } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - return FALSE; - } + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return FALSE; + } } t1 = Deref(ARG1); } @@ -4845,42 +4618,39 @@ p_instance( USES_REGS1 ) } } - - -Term -Yap_LUInstance(LogUpdClause *cl, UInt arity) -{ +Term Yap_LUInstance(LogUpdClause *cl, UInt arity) { CACHE_REGS - Term TermDB; + Term TermDB; op_numbers opc = Yap_op_from_opcode(cl->ClCode->opc); if (opc == _unify_idb_term) { TermDB = cl->lusl.ClSource->Entry; - } else { + } else { CACHE_REGS - int in_src; - - in_src = (opc != _copy_idb_term); - while ((TermDB = GetDBTerm(cl->lusl.ClSource, in_src PASS_REGS)) == 0L) { + int in_src; + + in_src = (opc != _copy_idb_term); + while ((TermDB = GetDBTerm(cl->lusl.ClSource, in_src PASS_REGS)) == 0L) { /* oops, we are in trouble, not enough stack space */ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - return 0L; - } + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return 0L; + } } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, arity, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - return 0L; - } + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, arity, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return 0L; + } } } } #if MULTIPLE_STACKS cl->ClRefCount++; - TRAIL_CLREF(cl); /* So that fail will erase it */ + TRAIL_CLREF(cl); /* So that fail will erase it */ #else if (!(cl->ClFlags & InUseMask)) { cl->ClFlags |= InUseMask; @@ -4888,13 +4658,10 @@ Yap_LUInstance(LogUpdClause *cl, UInt arity) } #endif return TermDB; -} - +} /* instance(+Ref,?Term) */ -static Int -p_instance_module( USES_REGS1 ) -{ +static Int p_instance_module(USES_REGS1) { Term t1 = Deref(ARG1); DBRef dbr; @@ -4921,29 +4688,23 @@ p_instance_module( USES_REGS1 ) } } -inline static int -NotActiveDB(DBRef my_dbref) -{ +inline static int NotActiveDB(DBRef my_dbref) { while (my_dbref && (my_dbref->Flags & (DBCode | ErasedMask))) my_dbref = my_dbref->Next; return (my_dbref == NIL); } -inline static DBEntry * -NextDBProp(PropEntry *pp) -{ - while (!EndOfPAEntr(pp) && (((pp->KindOfPE & ~ 0x1) != DBProperty) || - NotActiveDB(((DBProp) pp)->First))) +inline static DBEntry *NextDBProp(PropEntry *pp) { + while (!EndOfPAEntr(pp) && (((pp->KindOfPE & ~0x1) != DBProperty) || + NotActiveDB(((DBProp)pp)->First))) pp = RepProp(pp->NextOfPE); return ((DBEntry *)pp); } -static Int -init_current_key( USES_REGS1 ) -{ /* current_key(+Atom,?key) */ - Int i = 0; - DBEntry *pp; - Atom a; +static Int init_current_key(USES_REGS1) { /* current_key(+Atom,?key) */ + Int i = 0; + DBEntry *pp; + Atom a; Term t1 = ARG1; t1 = Deref(ARG1); @@ -4959,7 +4720,7 @@ init_current_key( USES_REGS1 ) READ_LOCK(HashChain[i].AERWLock); a = HashChain[i].Entry; if (a != NIL) { - break; + break; } READ_UNLOCK(HashChain[i].AERWLock); i++; @@ -4969,25 +4730,23 @@ init_current_key( USES_REGS1 ) READ_LOCK(RepAtom(a)->ARWLock); pp = NextDBProp(RepProp(RepAtom(a)->PropsOfAE)); READ_UNLOCK(RepAtom(a)->ARWLock); - EXTRA_CBACK_ARG(2,3) = MkAtomTerm(a); - EXTRA_CBACK_ARG(2,2) = MkIntTerm(i); - EXTRA_CBACK_ARG(2,1) = MkIntegerTerm((Int)pp); - return cont_current_key( PASS_REGS1 ); + EXTRA_CBACK_ARG(2, 3) = MkAtomTerm(a); + EXTRA_CBACK_ARG(2, 2) = MkIntTerm(i); + EXTRA_CBACK_ARG(2, 1) = MkIntegerTerm((Int)pp); + return cont_current_key(PASS_REGS1); } -static Int -cont_current_key( USES_REGS1 ) -{ - unsigned int arity; - Functor functor; - Term term, AtT; - Atom a; - Int i = IntegerOfTerm(EXTRA_CBACK_ARG(2,2)); - Term first = Deref(ARG1); - DBEntry *pp = (DBEntry *) IntegerOfTerm(EXTRA_CBACK_ARG(2,1)); +static Int cont_current_key(USES_REGS1) { + unsigned int arity; + Functor functor; + Term term, AtT; + Atom a; + Int i = IntegerOfTerm(EXTRA_CBACK_ARG(2, 2)); + Term first = Deref(ARG1); + DBEntry *pp = (DBEntry *)IntegerOfTerm(EXTRA_CBACK_ARG(2, 1)); - if (IsIntTerm(term = EXTRA_CBACK_ARG(2,3))) - return cont_current_key_integer( PASS_REGS1 ); + if (IsIntTerm(term = EXTRA_CBACK_ARG(2, 3))) + return cont_current_key_integer(PASS_REGS1); a = AtomOfTerm(term); if (EndOfPAEntr(pp) && IsAtomTerm(first)) { cut_fail(); @@ -4998,57 +4757,57 @@ cont_current_key( USES_REGS1 ) if ((a = RepAtom(a)->NextOfAE) == NIL) { i++; while (i < AtomHashTableSize) { - /* protect current hash table line, notice that the current - LOCK/UNLOCK algorithm assumes new entries are added to - the *front* of the list, otherwise I should have locked - earlier. - */ - READ_LOCK(HashChain[i].AERWLock); - a = HashChain[i].Entry; - if (a != NIL) { - break; - } - /* move to next entry */ - READ_UNLOCK(HashChain[i].AERWLock); - i++; + /* protect current hash table line, notice that the current + LOCK/UNLOCK algorithm assumes new entries are added to + the *front* of the list, otherwise I should have locked + earlier. + */ + READ_LOCK(HashChain[i].AERWLock); + a = HashChain[i].Entry; + if (a != NIL) { + break; + } + /* move to next entry */ + READ_UNLOCK(HashChain[i].AERWLock); + i++; } if (i == AtomHashTableSize) { - /* we have left the atom hash table */ - /* we don't have a lock over the hash table any longer */ - if (IsAtomTerm(first)) { - cut_fail(); - } - j = 0; - if (INT_KEYS == NULL) { - cut_fail(); - } - for(j = 0; j < INT_KEYS_SIZE; j++) { - if (INT_KEYS[j] != NIL) { - DBProp pptr = RepDBProp(INT_KEYS[j]); - EXTRA_CBACK_ARG(2,1) = MkIntegerTerm((Int)(pptr->NextOfPE)); - EXTRA_CBACK_ARG(2,2) = MkIntegerTerm(j+1); - EXTRA_CBACK_ARG(2,3) = MkIntTerm(INT_KEYS_TIMESTAMP); - term = MkIntegerTerm((Int)(pptr->FunctorOfDB)); - return Yap_unify(term,ARG1) && Yap_unify(term,ARG2); - } - } - if (j == INT_KEYS_SIZE) { - cut_fail(); - } - return cont_current_key_integer( PASS_REGS1 ); + /* we have left the atom hash table */ + /* we don't have a lock over the hash table any longer */ + if (IsAtomTerm(first)) { + cut_fail(); + } + j = 0; + if (INT_KEYS == NULL) { + cut_fail(); + } + for (j = 0; j < INT_KEYS_SIZE; j++) { + if (INT_KEYS[j] != NIL) { + DBProp pptr = RepDBProp(INT_KEYS[j]); + EXTRA_CBACK_ARG(2, 1) = MkIntegerTerm((Int)(pptr->NextOfPE)); + EXTRA_CBACK_ARG(2, 2) = MkIntegerTerm(j + 1); + EXTRA_CBACK_ARG(2, 3) = MkIntTerm(INT_KEYS_TIMESTAMP); + term = MkIntegerTerm((Int)(pptr->FunctorOfDB)); + return Yap_unify(term, ARG1) && Yap_unify(term, ARG2); + } + } + if (j == INT_KEYS_SIZE) { + cut_fail(); + } + return cont_current_key_integer(PASS_REGS1); } else { - /* release our lock over the hash table */ - READ_UNLOCK(HashChain[i].AERWLock); - EXTRA_CBACK_ARG(2,2) = MkIntTerm(i); + /* release our lock over the hash table */ + READ_UNLOCK(HashChain[i].AERWLock); + EXTRA_CBACK_ARG(2, 2) = MkIntTerm(i); } } READ_LOCK(RepAtom(a)->ARWLock); if (!EndOfPAEntr(pp = NextDBProp(RepProp(RepAtom(a)->PropsOfAE)))) - EXTRA_CBACK_ARG(2,3) = (CELL) MkAtomTerm(a); + EXTRA_CBACK_ARG(2, 3) = (CELL)MkAtomTerm(a); READ_UNLOCK(RepAtom(a)->ARWLock); } READ_LOCK(RepAtom(a)->ARWLock); - EXTRA_CBACK_ARG(2,1) = MkIntegerTerm((Int)NextDBProp(RepProp(pp->NextOfPE))); + EXTRA_CBACK_ARG(2, 1) = MkIntegerTerm((Int)NextDBProp(RepProp(pp->NextOfPE))); READ_UNLOCK(RepAtom(a)->ARWLock); arity = (unsigned int)(pp->ArityOfDB); if (arity == 0) { @@ -5067,24 +4826,22 @@ cont_current_key( USES_REGS1 ) return (Yap_unify_constant(ARG1, AtT) && Yap_unify(ARG2, term)); } -static Int -cont_current_key_integer( USES_REGS1 ) -{ - Term term; - UInt i = IntOfTerm(EXTRA_CBACK_ARG(2,2)); - Prop pp = (Prop)IntegerOfTerm(EXTRA_CBACK_ARG(2,1)); - UInt tstamp = (UInt)IntOfTerm(EXTRA_CBACK_ARG(2,3)); - DBProp pptr; +static Int cont_current_key_integer(USES_REGS1) { + Term term; + UInt i = IntOfTerm(EXTRA_CBACK_ARG(2, 2)); + Prop pp = (Prop)IntegerOfTerm(EXTRA_CBACK_ARG(2, 1)); + UInt tstamp = (UInt)IntOfTerm(EXTRA_CBACK_ARG(2, 3)); + DBProp pptr; if (tstamp != INT_KEYS_TIMESTAMP) { cut_fail(); } while (pp == NIL) { - for(;i < INT_KEYS_SIZE; i++) { + for (; i < INT_KEYS_SIZE; i++) { if (INT_KEYS[i] != NIL) { - EXTRA_CBACK_ARG(2,2) = MkIntTerm(i+1); - pp = INT_KEYS[i]; - break; + EXTRA_CBACK_ARG(2, 2) = MkIntTerm(i + 1); + pp = INT_KEYS[i]; + break; } } if (i == INT_KEYS_SIZE) { @@ -5092,28 +4849,22 @@ cont_current_key_integer( USES_REGS1 ) } } pptr = RepDBProp(pp); - EXTRA_CBACK_ARG(2,1) = MkIntegerTerm((Int)(pptr->NextOfPE)); + EXTRA_CBACK_ARG(2, 1) = MkIntegerTerm((Int)(pptr->NextOfPE)); term = MkIntegerTerm((Int)(pptr->FunctorOfDB)); - return Yap_unify(term,ARG1) && Yap_unify(term,ARG2); + return Yap_unify(term, ARG1) && Yap_unify(term, ARG2); } -Term -Yap_FetchTermFromDB(DBTerm *ref) -{ +Term Yap_FetchTermFromDB(DBTerm *ref) { CACHE_REGS - return GetDBTerm(ref, FALSE PASS_REGS); + return GetDBTerm(ref, FALSE PASS_REGS); } -Term -Yap_FetchClauseTermFromDB(DBTerm *ref) -{ +Term Yap_FetchClauseTermFromDB(DBTerm *ref) { CACHE_REGS - return GetDBTerm(ref, TRUE PASS_REGS); + return GetDBTerm(ref, TRUE PASS_REGS); } -Term -Yap_PopTermFromDB(DBTerm *ref) -{ +Term Yap_PopTermFromDB(DBTerm *ref) { CACHE_REGS Term t = GetDBTerm(ref, FALSE PASS_REGS); @@ -5122,85 +4873,73 @@ Yap_PopTermFromDB(DBTerm *ref) return t; } -static DBTerm * -StoreTermInDB(Term t, int nargs USES_REGS) -{ +static DBTerm *StoreTermInDB(Term t, int nargs USES_REGS) { DBTerm *x; int needs_vars; struct db_globs dbg; LOCAL_s_dbg = &dbg; LOCAL_Error_Size = 0; - while ((x = (DBTerm *)CreateDBStruct(t, (DBProp)NULL, - InQueue, &needs_vars, 0, &dbg)) == NULL) { + while ((x = (DBTerm *)CreateDBStruct(t, (DBProp)NULL, InQueue, &needs_vars, 0, + &dbg)) == NULL) { if (LOCAL_Error_TYPE == YAP_NO_ERROR) { break; } else if (nargs == -1) { return NULL; } else { - XREGS[nargs+1] = t; - if (recover_from_record_error(nargs+1)) { - t = Deref(XREGS[nargs+1]); + XREGS[nargs + 1] = t; + if (recover_from_record_error(nargs + 1)) { + t = Deref(XREGS[nargs + 1]); } else { - return NULL; + return NULL; } } } return x; } -DBTerm * -Yap_StoreTermInDB(Term t, int nargs) { +DBTerm *Yap_StoreTermInDB(Term t, int nargs) { CACHE_REGS return StoreTermInDB(t, nargs PASS_REGS); } -DBTerm * -Yap_StoreTermInDBPlusExtraSpace(Term t, UInt extra_size, UInt *sz) { +DBTerm *Yap_StoreTermInDBPlusExtraSpace(Term t, UInt extra_size, UInt *sz) { CACHE_REGS int needs_vars; struct db_globs dbg; DBTerm *o; LOCAL_s_dbg = &dbg; - o = (DBTerm *)CreateDBStruct(t, (DBProp)NULL, - InQueue, &needs_vars, extra_size, &dbg); + o = (DBTerm *)CreateDBStruct(t, (DBProp)NULL, InQueue, &needs_vars, + extra_size, &dbg); *sz = dbg.sz; return o; } -void -Yap_init_tqueue( db_queue *dbq ) -{ +void Yap_init_tqueue(db_queue *dbq) { dbq->id = FunctorDBRef; dbq->Flags = DBClMask; dbq->FirstInQueue = dbq->LastInQueue = NULL; INIT_RWLOCK(dbq->QRWLock); } -void -Yap_destroy_tqueue( db_queue *dbq USES_REGS) -{ - QueueEntry * cur_instance = dbq->FirstInQueue; +void Yap_destroy_tqueue(db_queue *dbq USES_REGS) { + QueueEntry *cur_instance = dbq->FirstInQueue; while (cur_instance) { - /* release space for cur_instance */ - keepdbrefs(cur_instance->DBT PASS_REGS); - ErasePendingRefs(cur_instance->DBT PASS_REGS); - FreeDBSpace((char *) cur_instance->DBT); - FreeDBSpace((char *) cur_instance); + /* release space for cur_instance */ + keepdbrefs(cur_instance->DBT PASS_REGS); + ErasePendingRefs(cur_instance->DBT PASS_REGS); + FreeDBSpace((char *)cur_instance->DBT); + FreeDBSpace((char *)cur_instance); } - dbq->FirstInQueue = - dbq->LastInQueue = NULL; - + dbq->FirstInQueue = dbq->LastInQueue = NULL; } -bool -Yap_enqueue_tqueue(db_queue *father_key, Term t USES_REGS) -{ +bool Yap_enqueue_tqueue(db_queue *father_key, Term t USES_REGS) { QueueEntry *x; while ((x = (QueueEntry *)AllocDBSpace(sizeof(QueueEntry))) == NULL) { if (!Yap_growheap(FALSE, sizeof(QueueEntry), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "in findall"); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "in findall"); return false; } } @@ -5217,98 +4956,90 @@ Yap_enqueue_tqueue(db_queue *father_key, Term t USES_REGS) father_key->FirstInQueue = x; } return true; - } -bool -Yap_dequeue_tqueue(db_queue *father_key, Term t, bool first, bool release USES_REGS) -{ +bool Yap_dequeue_tqueue(db_queue *father_key, Term t, bool first, + bool release USES_REGS) { Term TDB; - CELL *oldH = HR ; + CELL *oldH = HR; tr_fr_ptr oldTR = TR; - QueueEntry * cur_instance = father_key->FirstInQueue, *prev = NULL; + QueueEntry *cur_instance = father_key->FirstInQueue, *prev = NULL; while (cur_instance) { - HR = oldH; - HB = LCL0; - while ((TDB = GetDBTerm(cur_instance->DBT, false PASS_REGS)) == 0L) { - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); - return false; - } - } else { - LOCAL_Error_TYPE = YAP_NO_ERROR; - if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); - return false; - } - } - oldTR = TR; - oldH = HR; - } - if (Yap_unify(t, TDB)) { - if (release) { - if (cur_instance == father_key->FirstInQueue) { - father_key->FirstInQueue = cur_instance->next; - } - if (cur_instance == father_key->LastInQueue) { - father_key->LastInQueue = prev; - } - if (prev) { - prev->next = cur_instance->next; - } - /* release space for cur_instance */ - keepdbrefs(cur_instance->DBT PASS_REGS); - ErasePendingRefs(cur_instance->DBT PASS_REGS); - FreeDBSpace((char *) cur_instance->DBT); - FreeDBSpace((char *) cur_instance); - } else { - // undo if you'rejust peeking - while (oldTR < TR) { - CELL d1 = TrailTerm(TR-1); - TR--; - /* normal variable */ - RESET_VARIABLE(d1); - } - - } - return true; + HR = oldH; + HB = LCL0; + while ((TDB = GetDBTerm(cur_instance->DBT, false PASS_REGS)) == 0L) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_growglobal(NULL)) { + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, + LOCAL_ErrorMessage); + return false; + } } else { - // just getting the first - if (first) - return false; - // but keep on going, if we want to check everything. - prev = cur_instance; - cur_instance = cur_instance->next; + LOCAL_Error_TYPE = YAP_NO_ERROR; + if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); + return false; + } } + oldTR = TR; + oldH = HR; + } + if (Yap_unify(t, TDB)) { + if (release) { + if (cur_instance == father_key->FirstInQueue) { + father_key->FirstInQueue = cur_instance->next; + } + if (cur_instance == father_key->LastInQueue) { + father_key->LastInQueue = prev; + } + if (prev) { + prev->next = cur_instance->next; + } + /* release space for cur_instance */ + keepdbrefs(cur_instance->DBT PASS_REGS); + ErasePendingRefs(cur_instance->DBT PASS_REGS); + FreeDBSpace((char *)cur_instance->DBT); + FreeDBSpace((char *)cur_instance); + } else { + // undo if you'rejust peeking + while (oldTR < TR) { + CELL d1 = TrailTerm(TR - 1); + TR--; + /* normal variable */ + RESET_VARIABLE(d1); + } + } + return true; + } else { + // just getting the first + if (first) + return false; + // but keep on going, if we want to check everything. + prev = cur_instance; + cur_instance = cur_instance->next; + } } return false; - } -static Int -p_init_queue( USES_REGS1 ) -{ +static Int p_init_queue(USES_REGS1) { db_queue *dbq; Term t; while ((dbq = (db_queue *)AllocDBSpace(sizeof(db_queue))) == NULL) { if (!Yap_growheap(FALSE, sizeof(db_queue), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "in findall"); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "in findall"); return FALSE; } } /* Yap_LUClauseSpace += sizeof(db_queue); */ - Yap_init_tqueue( dbq ); + Yap_init_tqueue(dbq); t = MkIntegerTerm((Int)dbq); return Yap_unify(ARG1, t); } - -static Int -p_enqueue( USES_REGS1 ) -{ +static Int p_enqueue(USES_REGS1) { Term Father = Deref(ARG1); db_queue *father_key; bool rc; @@ -5327,9 +5058,7 @@ p_enqueue( USES_REGS1 ) return rc; } -static Int -p_enqueue_unlocked( USES_REGS1 ) -{ +static Int p_enqueue_unlocked(USES_REGS1) { Term Father = Deref(ARG1); db_queue *father_key; @@ -5347,146 +5076,129 @@ p_enqueue_unlocked( USES_REGS1 ) /* when reading an entry in the data base we are making it accessible from the outside. If the entry was removed, and this was the last pointer, the target entry would be immediately removed, leading to dangling pointers. - We avoid this problem by making every entry accessible. + We avoid this problem by making every entry accessible. Note that this could not happen with recorded, because the original db entry itself is still accessible from a trail entry, so we could not remove the target entry, */ -static void -keepdbrefs(DBTerm *entryref USES_REGS) -{ - DBRef *cp; - DBRef ref; +static void keepdbrefs(DBTerm *entryref USES_REGS) { + DBRef *cp; + DBRef ref; cp = entryref->DBRefs; if (cp == NULL) { return; } while ((ref = *--cp) != NIL) { - if (!(ref->Flags & LogUpdMask)) { - LOCK(ref->lock); - if(!(ref->Flags & InUseMask)) { - ref->Flags |= InUseMask; - TRAIL_REF(ref); /* So that fail will erase it */ - } - UNLOCK(ref->lock); + if (!(ref->Flags & LogUpdMask)) { + LOCK(ref->lock); + if (!(ref->Flags & InUseMask)) { + ref->Flags |= InUseMask; + TRAIL_REF(ref); /* So that fail will erase it */ } + UNLOCK(ref->lock); + } } - } -static Int -p_dequeue( USES_REGS1 ) -{ +static Int p_dequeue(USES_REGS1) { db_queue *father_key; QueueEntry *cur_instance; Term Father = Deref(ARG1); if (IsVarTerm(Father)) { - Yap_Error(INSTANTIATION_ERROR, Father, "dequeue"); - return FALSE; + Yap_Error(INSTANTIATION_ERROR, Father, "dequeue"); + return FALSE; } else if (!IsIntegerTerm(Father)) { - Yap_Error(TYPE_ERROR_INTEGER, Father, "dequeue"); - return FALSE; + Yap_Error(TYPE_ERROR_INTEGER, Father, "dequeue"); + return FALSE; } else { - father_key = (db_queue *)IntegerOfTerm(Father); - WRITE_LOCK(father_key->QRWLock); - if ((cur_instance = father_key->FirstInQueue) == NULL) { - /* an empty queue automatically goes away */ - WRITE_UNLOCK(father_key->QRWLock); - FreeDBSpace((char *)father_key); - return FALSE; - } - if (!Yap_dequeue_tqueue(father_key, ARG2, true, true PASS_REGS) ) - return FALSE; - if (cur_instance == father_key->LastInQueue) - father_key->FirstInQueue = father_key->LastInQueue = NULL; - else - father_key->FirstInQueue = cur_instance->next; + father_key = (db_queue *)IntegerOfTerm(Father); + WRITE_LOCK(father_key->QRWLock); + if ((cur_instance = father_key->FirstInQueue) == NULL) { + /* an empty queue automatically goes away */ WRITE_UNLOCK(father_key->QRWLock); - return TRUE; + FreeDBSpace((char *)father_key); + return FALSE; + } + if (!Yap_dequeue_tqueue(father_key, ARG2, true, true PASS_REGS)) + return FALSE; + if (cur_instance == father_key->LastInQueue) + father_key->FirstInQueue = father_key->LastInQueue = NULL; + else + father_key->FirstInQueue = cur_instance->next; + WRITE_UNLOCK(father_key->QRWLock); + return TRUE; } } - -static Int -p_dequeue_unlocked( USES_REGS1 ) -{ +static Int p_dequeue_unlocked(USES_REGS1) { db_queue *father_key; QueueEntry *cur_instance; Term Father = Deref(ARG1); if (IsVarTerm(Father)) { - Yap_Error(INSTANTIATION_ERROR, Father, "dequeue"); - return FALSE; + Yap_Error(INSTANTIATION_ERROR, Father, "dequeue"); + return FALSE; } else if (!IsIntegerTerm(Father)) { - Yap_Error(TYPE_ERROR_INTEGER, Father, "dequeue"); - return FALSE; + Yap_Error(TYPE_ERROR_INTEGER, Father, "dequeue"); + return FALSE; } else { - father_key = (db_queue *)IntegerOfTerm(Father); - if ((cur_instance = father_key->FirstInQueue) == NULL) { - /* an empty queue automatically goes away */ - FreeDBSpace((char *)father_key); - return FALSE; - } - if (!Yap_dequeue_tqueue(father_key, ARG2, true, true PASS_REGS) ) - return FALSE; - if (cur_instance == father_key->LastInQueue) - father_key->FirstInQueue = father_key->LastInQueue = NULL; - else - father_key->FirstInQueue = cur_instance->next; - return TRUE; + father_key = (db_queue *)IntegerOfTerm(Father); + if ((cur_instance = father_key->FirstInQueue) == NULL) { + /* an empty queue automatically goes away */ + FreeDBSpace((char *)father_key); + return FALSE; + } + if (!Yap_dequeue_tqueue(father_key, ARG2, true, true PASS_REGS)) + return FALSE; + if (cur_instance == father_key->LastInQueue) + father_key->FirstInQueue = father_key->LastInQueue = NULL; + else + father_key->FirstInQueue = cur_instance->next; + return TRUE; } } -static Int -p_peek_queue( USES_REGS1 ) -{ +static Int p_peek_queue(USES_REGS1) { db_queue *father_key; QueueEntry *cur_instance; Term Father = Deref(ARG1); if (IsVarTerm(Father)) { - Yap_Error(INSTANTIATION_ERROR, Father, "dequeue"); - return FALSE; + Yap_Error(INSTANTIATION_ERROR, Father, "dequeue"); + return FALSE; } else if (!IsIntegerTerm(Father)) { - Yap_Error(TYPE_ERROR_INTEGER, Father, "dequeue"); - return FALSE; + Yap_Error(TYPE_ERROR_INTEGER, Father, "dequeue"); + return FALSE; } else { - father_key = (db_queue *)IntegerOfTerm(Father); - if ((cur_instance = father_key->FirstInQueue) == NULL) { - /* an empty queue automatically goes away */ - FreeDBSpace((char *)father_key); - return FALSE; - } - if (!Yap_dequeue_tqueue(father_key, ARG2, true, false PASS_REGS) ) - return FALSE; - if (cur_instance == father_key->LastInQueue) - father_key->FirstInQueue = father_key->LastInQueue = NULL; - else - father_key->FirstInQueue = cur_instance->next; - return TRUE; + father_key = (db_queue *)IntegerOfTerm(Father); + if ((cur_instance = father_key->FirstInQueue) == NULL) { + /* an empty queue automatically goes away */ + FreeDBSpace((char *)father_key); + return FALSE; + } + if (!Yap_dequeue_tqueue(father_key, ARG2, true, false PASS_REGS)) + return FALSE; + if (cur_instance == father_key->LastInQueue) + father_key->FirstInQueue = father_key->LastInQueue = NULL; + else + father_key->FirstInQueue = cur_instance->next; + return TRUE; } } - -static Int -p_clean_queues( USES_REGS1 ) -{ - return TRUE; -} +static Int p_clean_queues(USES_REGS1) { return TRUE; } /* set the logical updates flag */ -static Int -p_slu( USES_REGS1 ) -{ +static Int p_slu(USES_REGS1) { Term t = Deref(ARG1); - if (IsVarTerm(t)) { + if (IsVarTerm(t)) { Yap_Error(INSTANTIATION_ERROR, t, "switch_logical_updates/1"); return FALSE; - } - if (!IsIntTerm(t)) { + } + if (!IsIntTerm(t)) { Yap_Error(TYPE_ERROR_INTEGER, t, "switch_logical_updates/1"); return FALSE; } @@ -5495,23 +5207,15 @@ p_slu( USES_REGS1 ) } /* check current status for logical updates */ -static Int -p_lu( USES_REGS1 ) -{ - return Yap_unify(ARG1,MkIntTerm(UPDATE_MODE)); -} +static Int p_lu(USES_REGS1) { return Yap_unify(ARG1, MkIntTerm(UPDATE_MODE)); } -/* get a hold over the index table for logical update predicates */ -static Int -p_hold_index( USES_REGS1 ) -{ - Yap_Error(SYSTEM_ERROR, TermNil, "hold_index in debugger"); +/* get a hold over the index table for logical update predicates */ +static Int p_hold_index(USES_REGS1) { + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "hold_index in debugger"); return FALSE; } -static Int -p_fetch_reference_from_index( USES_REGS1 ) -{ +static Int p_fetch_reference_from_index(USES_REGS1) { Term t1 = Deref(ARG1), t2 = Deref(ARG2); DBRef table, el; Int pos; @@ -5526,7 +5230,7 @@ p_fetch_reference_from_index( USES_REGS1 ) el = (DBRef)(table->DBT.Contents[pos]); LOCK(el->lock); #if MULTIPLE_STACKS - TRAIL_REF(el); /* So that fail will erase it */ + TRAIL_REF(el); /* So that fail will erase it */ INC_DBREF_COUNT(el); #else if (!(el->Flags & InUseMask)) { @@ -5538,12 +5242,10 @@ p_fetch_reference_from_index( USES_REGS1 ) return Yap_unify(ARG3, MkDBRefTerm(el)); } -static Int -p_resize_int_keys( USES_REGS1 ) -{ +static Int p_resize_int_keys(USES_REGS1) { Term t1 = Deref(ARG1); if (IsVarTerm(t1)) { - return Yap_unify(ARG1,MkIntegerTerm((Int)INT_KEYS_SIZE)); + return Yap_unify(ARG1, MkIntegerTerm((Int)INT_KEYS_SIZE)); } if (!IsIntegerTerm(t1)) { Yap_Error(TYPE_ERROR_INTEGER, t1, "yap_flag(resize_db_int_keys,T)"); @@ -5552,65 +5254,62 @@ p_resize_int_keys( USES_REGS1 ) return resize_int_keys(IntegerOfTerm(t1)); } -static void -ReleaseTermFromDB(DBTerm *ref USES_REGS) -{ +static void ReleaseTermFromDB(DBTerm *ref USES_REGS) { if (!ref) return; keepdbrefs(ref PASS_REGS); ErasePendingRefs(ref PASS_REGS); - FreeDBSpace((char *) ref); + FreeDBSpace((char *)ref); } -void -Yap_ReleaseTermFromDB(DBTerm *ref) -{ +void Yap_ReleaseTermFromDB(DBTerm *ref) { CACHE_REGS ReleaseTermFromDB(ref PASS_REGS); } -static Int -p_install_thread_local( USES_REGS1 ) -{ /* '$is_dynamic'(+P) */ - PredEntry *pe; - Term t = Deref(ARG1); - Term mod = Deref(ARG2); +static Int p_install_thread_local(USES_REGS1) { /* '$is_dynamic'(+P) */ + PredEntry *pe; + Term t = Deref(ARG1); + Term mod = Deref(ARG2); if (IsVarTerm(t)) { return (FALSE); } if (mod == IDB_MODULE) { - pe = find_lu_entry(t); + pe = find_lu_entry(t); if (!pe->cs.p_code.NOfClauses) { - if (IsIntegerTerm(t)) - pe->PredFlags |= LogUpdatePredFlag|NumberDBPredFlag; + if (IsIntegerTerm(t)) + pe->PredFlags |= LogUpdatePredFlag | NumberDBPredFlag; else if (IsAtomTerm(t)) - pe->PredFlags |= LogUpdatePredFlag|AtomDBPredFlag; + pe->PredFlags |= LogUpdatePredFlag | AtomDBPredFlag; else - pe->PredFlags |= LogUpdatePredFlag; + pe->PredFlags |= LogUpdatePredFlag; } } else if (IsAtomTerm(t)) { Atom at = AtomOfTerm(t); pe = RepPredProp(PredPropByAtom(at, mod)); } else if (IsApplTerm(t)) { - Functor fun = FunctorOfTerm(t); + Functor fun = FunctorOfTerm(t); pe = RepPredProp(PredPropByFunc(fun, mod)); } else { return FALSE; } - PELOCK(69,pe); - if (pe->PredFlags & (ThreadLocalPredFlag|LogUpdatePredFlag)) { + PELOCK(69, pe); + if (pe->PredFlags & (ThreadLocalPredFlag | LogUpdatePredFlag)) { // second declaration, just ignore UNLOCK(pe->PELock); return TRUE; } - if (pe->PredFlags & (UserCPredFlag|HiddenPredFlag|CArgsPredFlag|SyncPredFlag|TestPredFlag|AsmPredFlag|StandardPredFlag|CPredFlag|SafePredFlag|IndexedPredFlag|BinaryPredFlag) || + if (pe->PredFlags & + (UserCPredFlag | HiddenPredFlag | CArgsPredFlag | SyncPredFlag | + TestPredFlag | AsmPredFlag | StandardPredFlag | CPredFlag | + SafePredFlag | IndexedPredFlag | BinaryPredFlag) || pe->cs.p_code.NOfClauses) { UNLOCK(pe->PELock); return FALSE; } #if THREADS - pe->PredFlags |= ThreadLocalPredFlag|LogUpdatePredFlag; + pe->PredFlags |= ThreadLocalPredFlag | LogUpdatePredFlag; pe->OpcodeOfPred = Yap_opcode(_thread_local); pe->CodeOfPred = (yamop *)&pe->OpcodeOfPred; #else @@ -5620,34 +5319,32 @@ p_install_thread_local( USES_REGS1 ) return TRUE; } -void -Yap_InitDBPreds(void) -{ +void Yap_InitDBPreds(void) { Yap_InitCPred("recorded", 3, p_recorded, SyncPredFlag); -/** @pred recorded(+ _K_, _T_, _R_) + /** @pred recorded(+ _K_, _T_, _R_) -Searches in the internal database under the key _K_, a term that -unifies with _T_ and whose reference matches _R_. This -built-in may be used in one of two ways: + Searches in the internal database under the key _K_, a term that + unifies with _T_ and whose reference matches _R_. This + built-in may be used in one of two ways: -+ _K_ may be given, in this case the built-in will return all -elements of the internal data-base that match the key. -+ _R_ may be given, if so returning the key and element that -match the reference. + + _K_ may be given, in this case the built-in will return all + elements of the internal data-base that match the key. + + _R_ may be given, if so returning the key and element that + match the reference. - -*/ + + */ Yap_InitCPred("recorda", 3, p_rcda, SyncPredFlag); -/** @pred recorda(+ _K_, _T_,- _R_) + /** @pred recorda(+ _K_, _T_,- _R_) -Makes term _T_ the first record under key _K_ and unifies _R_ -with its reference. + Makes term _T_ the first record under key _K_ and unifies _R_ + with its reference. - -*/ + + */ Yap_InitCPred("recordz", 3, p_rcdz, SyncPredFlag); Yap_InitCPred("$still_variant", 2, p_still_variant, SyncPredFlag); Yap_InitCPred("recorda_at", 3, p_rcda_at, SyncPredFlag); @@ -5656,19 +5353,27 @@ with its reference. Yap_InitCPred("$recordzp", 3, p_rcdzp, SyncPredFlag); Yap_InitCPred("$recordap", 4, p_drcdap, SyncPredFlag); Yap_InitCPred("$recordzp", 4, p_drcdzp, SyncPredFlag); - Yap_InitCPred("erase", 1, p_erase, SafePredFlag|SyncPredFlag); - Yap_InitCPred("$erase_clause", 2, p_erase_clause, SafePredFlag|SyncPredFlag); - Yap_InitCPred("increase_reference_count", 1, p_increase_reference_counter, SafePredFlag|SyncPredFlag); - Yap_InitCPred("decrease_reference_count", 1, p_decrease_reference_counter, SafePredFlag|SyncPredFlag); - Yap_InitCPred("current_reference_count", 2, p_current_reference_counter, SafePredFlag|SyncPredFlag); - Yap_InitCPred("erased", 1, p_erased, TestPredFlag | SafePredFlag|SyncPredFlag); + Yap_InitCPred("erase", 1, p_erase, SafePredFlag | SyncPredFlag); + Yap_InitCPred("$erase_clause", 2, p_erase_clause, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("increase_reference_count", 1, p_increase_reference_counter, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("decrease_reference_count", 1, p_decrease_reference_counter, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("current_reference_count", 2, p_current_reference_counter, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("erased", 1, p_erased, + TestPredFlag | SafePredFlag | SyncPredFlag); Yap_InitCPred("instance", 2, p_instance, SyncPredFlag); Yap_InitCPred("$instance_module", 2, p_instance_module, SyncPredFlag); - Yap_InitCPred("eraseall", 1, p_eraseall, SafePredFlag|SyncPredFlag); - Yap_InitCPred("$record_stat_source", 4, p_rcdstatp, SafePredFlag|SyncPredFlag); - Yap_InitCPred("$some_recordedp", 1, p_somercdedp, SafePredFlag|SyncPredFlag); - Yap_InitCPred("$first_instance", 3, p_first_instance, SafePredFlag|SyncPredFlag); - Yap_InitCPred("$init_db_queue", 1, p_init_queue, SafePredFlag|SyncPredFlag); + Yap_InitCPred("eraseall", 1, p_eraseall, SafePredFlag | SyncPredFlag); + Yap_InitCPred("$record_stat_source", 4, p_rcdstatp, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("$some_recordedp", 1, p_somercdedp, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("$first_instance", 3, p_first_instance, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("$init_db_queue", 1, p_init_queue, SafePredFlag | SyncPredFlag); Yap_InitCPred("$db_key", 2, p_db_key, 0L); Yap_InitCPred("$db_enqueue", 2, p_enqueue, SyncPredFlag); Yap_InitCPred("$db_enqueue_unlocked", 2, p_enqueue_unlocked, SyncPredFlag); @@ -5676,29 +5381,37 @@ with its reference. Yap_InitCPred("$db_dequeue_unlocked", 2, p_dequeue_unlocked, SyncPredFlag); Yap_InitCPred("$db_peek_queue", 2, p_peek_queue, SyncPredFlag); Yap_InitCPred("$db_clean_queues", 1, p_clean_queues, SyncPredFlag); - Yap_InitCPred("$switch_log_upd", 1, p_slu, SafePredFlag|SyncPredFlag); - Yap_InitCPred("$log_upd", 1, p_lu, SafePredFlag|SyncPredFlag); - Yap_InitCPred("$hold_index", 3, p_hold_index, SafePredFlag|SyncPredFlag); - Yap_InitCPred("$fetch_reference_from_index", 3, p_fetch_reference_from_index, SafePredFlag|SyncPredFlag); - Yap_InitCPred("$resize_int_keys", 1, p_resize_int_keys, SafePredFlag|SyncPredFlag); + Yap_InitCPred("$switch_log_upd", 1, p_slu, SafePredFlag | SyncPredFlag); + Yap_InitCPred("$log_upd", 1, p_lu, SafePredFlag | SyncPredFlag); + Yap_InitCPred("$hold_index", 3, p_hold_index, SafePredFlag | SyncPredFlag); + Yap_InitCPred("$fetch_reference_from_index", 3, p_fetch_reference_from_index, + SafePredFlag | SyncPredFlag); + Yap_InitCPred("$resize_int_keys", 1, p_resize_int_keys, + SafePredFlag | SyncPredFlag); Yap_InitCPred("key_statistics", 4, p_key_statistics, SyncPredFlag); Yap_InitCPred("$lu_statistics", 5, p_lu_statistics, SyncPredFlag); Yap_InitCPred("total_erased", 4, p_total_erased, SyncPredFlag); - Yap_InitCPred("key_erased_statistics", 5, p_key_erased_statistics, SyncPredFlag); + Yap_InitCPred("key_erased_statistics", 5, p_key_erased_statistics, + SyncPredFlag); Yap_InitCPred("heap_space_info", 3, p_heap_space_info, SyncPredFlag); - Yap_InitCPred("$jump_to_next_dynamic_clause", 0, p_jump_to_next_dynamic_clause, SyncPredFlag); - Yap_InitCPred("$install_thread_local", 2, p_install_thread_local, SafePredFlag); + Yap_InitCPred("$jump_to_next_dynamic_clause", 0, + p_jump_to_next_dynamic_clause, SyncPredFlag); + Yap_InitCPred("$install_thread_local", 2, p_install_thread_local, + SafePredFlag); } -void -Yap_InitBackDB(void) -{ - Yap_InitCPredBack("$recorded_with_key", 3, 3, in_rded_with_key, co_rded, SyncPredFlag); - RETRY_C_RECORDED_K_CODE = NEXTOP(PredRecordedWithKey->cs.p_code.FirstClause,OtapFs); +void Yap_InitBackDB(void) { + Yap_InitCPredBack("$recorded_with_key", 3, 3, in_rded_with_key, co_rded, + SyncPredFlag); + RETRY_C_RECORDED_K_CODE = + NEXTOP(PredRecordedWithKey->cs.p_code.FirstClause, OtapFs); Yap_InitCPredBack("$recordedp", 3, 3, in_rdedp, co_rdedp, SyncPredFlag); - RETRY_C_RECORDEDP_CODE = NEXTOP(RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomRecordedP, 3),0))->cs.p_code.FirstClause,OtapFs); - Yap_InitCPredBack("$current_immediate_key", 2, 4, init_current_key, cont_current_key, - SyncPredFlag); + RETRY_C_RECORDEDP_CODE = + NEXTOP(RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomRecordedP, 3), 0)) + ->cs.p_code.FirstClause, + OtapFs); + Yap_InitCPredBack("$current_immediate_key", 2, 4, init_current_key, + cont_current_key, SyncPredFlag); } /** diff --git a/C/dlmalloc.c b/C/dlmalloc.c index 9ec17147b..e7ddcb1dd 100644 --- a/C/dlmalloc.c +++ b/C/dlmalloc.c @@ -180,7 +180,7 @@ void Yap_add_memory_hole(ADDR start, ADDR end) { if (Yap_NOfMemoryHoles == MAX_DLMALLOC_HOLES) { - Yap_Error(OPERATING_SYSTEM_ERROR, 0L, "Unexpected Too Much Memory Fragmentation: please contact YAP maintainers"); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, 0L, "Unexpected Too Much Memory Fragmentation: please contact YAP maintainers"); return; } Yap_MemoryHoles[Yap_NOfMemoryHoles].start = start; diff --git a/C/errors.c b/C/errors.c index 15a4324b5..459cb36a9 100755 --- a/C/errors.c +++ b/C/errors.c @@ -1,20 +1,20 @@ /************************************************************************* -* * -* Yap Prolog * -* * -* Yap Prolog Was Developed At Nccup - Universidade Do Porto * -* * -* Copyright L.Damas, V.S.Costa And Universidade Do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: errors.c * -* Last Rev: * -* Mods: * -* Comments: Yap'S error handlers * -* * -*************************************************************************/ + * * + * Yap Prolog * + * * + * Yap Prolog Was Developed At Nccup - Universidade Do Porto * + * * + * Copyright L.Damas, V.S.Costa And Universidade Do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: errors.c * + * Last Rev: * + * Mods: * + * Comments: Yap'S error handlers * + * * + *************************************************************************/ #include "absmi.h" #include "yapio.h" @@ -30,110 +30,105 @@ #endif #include "Foreign.h" -static bool handled_exception( USES_REGS1 ); #if DEBUG -void -Yap_PrintPredName( PredEntry *ap ) -{ - CACHE_REGS +void Yap_PrintPredName(PredEntry *ap) { + CACHE_REGS Term tmod = ap->ModuleOfPred; - if (!tmod) tmod = TermProlog; + if (!tmod) + tmod = TermProlog; #if THREADS - Yap_DebugPlWrite(MkIntegerTerm(worker_id)); - Yap_DebugPutc(stderr,' '); + Yap_DebugPlWrite(MkIntegerTerm(worker_id)); + Yap_DebugPutc(stderr, ' '); #endif - Yap_DebugPutc(stderr,'>'); - Yap_DebugPutc(stderr,'\t'); - Yap_DebugPlWrite(tmod); - Yap_DebugPutc(stderr,':'); - if (ap->ModuleOfPred == IDB_MODULE) { - Term t = Deref(ARG1); - if (IsAtomTerm(t)) { - Yap_DebugPlWrite(t); - } else if (IsIntegerTerm(t)) { - Yap_DebugPlWrite(t); - } else { - Functor f = FunctorOfTerm(t); - Atom At = NameOfFunctor(f); - Yap_DebugPlWrite(MkAtomTerm(At)); - Yap_DebugPutc(stderr,'/'); - Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); - } + Yap_DebugPutc(stderr, '>'); + Yap_DebugPutc(stderr, '\t'); + Yap_DebugPlWrite(tmod); + Yap_DebugPutc(stderr, ':'); + if (ap->ModuleOfPred == IDB_MODULE) { + Term t = Deref(ARG1); + if (IsAtomTerm(t)) { + Yap_DebugPlWrite(t); + } else if (IsIntegerTerm(t)) { + Yap_DebugPlWrite(t); } else { - if (ap->ArityOfPE == 0) { - Atom At = (Atom)ap->FunctorOfPred; - Yap_DebugPlWrite(MkAtomTerm(At)); - } else { - Functor f = ap->FunctorOfPred; - Atom At = NameOfFunctor(f); - Yap_DebugPlWrite(MkAtomTerm(At)); - Yap_DebugPutc(stderr,'/'); - Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); - } + Functor f = FunctorOfTerm(t); + Atom At = NameOfFunctor(f); + Yap_DebugPlWrite(MkAtomTerm(At)); + Yap_DebugPutc(stderr, '/'); + Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); } - char s[1024]; - if (ap->PredFlags & StandardPredFlag) - fprintf(stderr,"S"); - if (ap->PredFlags & CPredFlag) - fprintf(stderr,"C"); - if (ap->PredFlags & UserCPredFlag) - fprintf(stderr,"U"); - if (ap->PredFlags & SyncPredFlag) - fprintf(stderr,"Y"); - if (ap->PredFlags & LogUpdatePredFlag) - fprintf(stderr,"Y"); - if (ap->PredFlags & HiddenPredFlag) - fprintf(stderr,"H"); - sprintf(s," %llx\n",ap->PredFlags); - Yap_DebugPuts(stderr,s); + } else { + if (ap->ArityOfPE == 0) { + Atom At = (Atom)ap->FunctorOfPred; + Yap_DebugPlWrite(MkAtomTerm(At)); + } else { + Functor f = ap->FunctorOfPred; + Atom At = NameOfFunctor(f); + Yap_DebugPlWrite(MkAtomTerm(At)); + Yap_DebugPutc(stderr, '/'); + Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); + } + } + char s[1024]; + if (ap->PredFlags & StandardPredFlag) + fprintf(stderr, "S"); + if (ap->PredFlags & CPredFlag) + fprintf(stderr, "C"); + if (ap->PredFlags & UserCPredFlag) + fprintf(stderr, "U"); + if (ap->PredFlags & SyncPredFlag) + fprintf(stderr, "Y"); + if (ap->PredFlags & LogUpdatePredFlag) + fprintf(stderr, "Y"); + if (ap->PredFlags & HiddenPredFlag) + fprintf(stderr, "H"); + sprintf(s, " %llx\n", ap->PredFlags); + Yap_DebugPuts(stderr, s); } #endif -bool -Yap_Warning( const char *s, ... ) -{ +bool Yap_Warning(const char *s, ...) { va_list args; va_start(args, s); - fprintf(stderr,"warning: %s\n", s); + fprintf(stderr, "warning: %s\n", s); va_end(args); return true; } -bool -Yap_PrintWarning( Term twarning ) -{ +bool Yap_PrintWarning(Term twarning) { CACHE_REGS - PredEntry * pred = RepPredProp(PredPropByFunc(FunctorPrintMessage,PROLOG_MODULE)); //PROCEDURE_print_message2; + PredEntry *pred = RepPredProp(PredPropByFunc( + FunctorPrintMessage, PROLOG_MODULE)); // PROCEDURE_print_message2; bool rc; Term ts[2]; - + if (LOCAL_within_print_message) { /* error within error */ - fprintf(stderr,"%% WARNING WITHIN WARNING\n"); - Yap_RestartYap( 1 ); + fprintf(stderr, "%% WARNING WITHIN WARNING\n"); + Yap_RestartYap(1); } LOCAL_DoingUndefp = true; LOCAL_within_print_message = true; if (pred->OpcodeOfPred == UNDEF_OPCODE) { fprintf(stderr, "warning message:\n"); - Yap_DebugPlWrite( twarning ); + Yap_DebugPlWrite(twarning); fprintf(stderr, "\n"); LOCAL_DoingUndefp = false; LOCAL_within_print_message = false; return true; } - ts[0] = MkAtomTerm( AtomWarning ); + ts[0] = MkAtomTerm(AtomWarning); ts[1] = twarning; - rc = Yap_execute_pred( pred, ts , true PASS_REGS); + rc = Yap_execute_pred(pred, ts, true PASS_REGS); LOCAL_within_print_message = false; LOCAL_DoingUndefp = false; return rc; } -int Yap_HandleError( const char *s, ... ) { +int Yap_HandleError(const char *s, ...) { CACHE_REGS yap_error_number err = LOCAL_Error_TYPE; const char *serr; @@ -145,35 +140,34 @@ int Yap_HandleError( const char *s, ... ) { serr = s; } switch (err) { - case OUT_OF_STACK_ERROR: - if (!Yap_gc(2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, serr); - return(FALSE); + case RESOURCE_ERROR_STACK: + if (!Yap_gc(2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, ARG1, serr); + return (FALSE); } return TRUE; - case OUT_OF_AUXSPACE_ERROR: - if (LOCAL_MAX_SIZE < (char *)AuxSp-AuxBase) { + case RESOURCE_ERROR_AUXILIARY_STACK: + if (LOCAL_MAX_SIZE < (char *)AuxSp - AuxBase) { LOCAL_MAX_SIZE += 1024; } - if (!Yap_ExpandPreAllocCodeSpace(0,NULL, TRUE)) { + if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { /* crash in flames */ - Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, serr); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, serr); return FALSE; } return TRUE; - case OUT_OF_HEAP_ERROR: + case RESOURCE_ERROR_HEAP: if (!Yap_growheap(FALSE, 0, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, ARG2, serr); + Yap_Error(RESOURCE_ERROR_HEAP, ARG2, serr); return FALSE; } default: Yap_Error(err, LOCAL_Error_Term, serr); - return(FALSE); + return (FALSE); } } - -int Yap_SWIHandleError( const char *s, ... ) -{ + +int Yap_SWIHandleError(const char *s, ...) { CACHE_REGS yap_error_number err = LOCAL_Error_TYPE; char *serr; @@ -185,554 +179,233 @@ int Yap_SWIHandleError( const char *s, ... ) serr = (char *)s; } switch (err) { - case OUT_OF_STACK_ERROR: - if (!Yap_gc(2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, serr); - return(FALSE); + case RESOURCE_ERROR_STACK: + if (!Yap_gc(2, ENV, gc_P(P, CP))) { + Yap_Error(RESOURCE_ERROR_STACK, TermNil, serr); + return (FALSE); } return TRUE; - case OUT_OF_AUXSPACE_ERROR: - if (LOCAL_MAX_SIZE < (char *)AuxSp-AuxBase) { + case RESOURCE_ERROR_AUXILIARY_STACK: + if (LOCAL_MAX_SIZE < (char *)AuxSp - AuxBase) { LOCAL_MAX_SIZE += 1024; } - if (!Yap_ExpandPreAllocCodeSpace(0,NULL, TRUE)) { + if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { /* crash in flames */ - Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, serr); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, serr); return FALSE; } return TRUE; - case OUT_OF_HEAP_ERROR: + case RESOURCE_ERROR_HEAP: if (!Yap_growheap(FALSE, 0, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, ARG2, serr); + Yap_Error(RESOURCE_ERROR_HEAP, ARG2, serr); return FALSE; } default: Yap_Error(err, LOCAL_Error_Term, serr); - return(FALSE); + return (FALSE); } } -void -Yap_RestartYap ( int flag ) -{ +void Yap_RestartYap(int flag) { CACHE_REGS #if PUSH_REGS - restore_absmi_regs(&Yap_standard_regs); + restore_absmi_regs(&Yap_standard_regs); #endif - siglongjmp(LOCAL_RestartEnv,1); + siglongjmp(LOCAL_RestartEnv, 1); } -void DumpActiveGoals( CACHE_TYPE1 ); -static int hidden(Atom); -static int legal_env(CELL * CACHE_TYPE); -static void detect_bug_location(yamop *,find_pred_type,char *, int); - -#define ONHEAP(ptr) (CellPtr(ptr) >= CellPtr(Yap_HeapBase) && CellPtr(ptr) < CellPtr(HeapTop)) - -#define ONLOCAL(ptr) (CellPtr(ptr) > CellPtr(HR) && CellPtr(ptr) < CellPtr(LOCAL_LocalBase)) - -static int -hidden (Atom at) -{ - AtomEntry *chain; - - READ_LOCK(INVISIBLECHAIN.AERWLock); - chain = RepAtom(INVISIBLECHAIN.Entry); - while (!EndOfPAEntr (chain) && AbsAtom (chain) != at) - chain = RepAtom(chain->NextOfAE); - READ_UNLOCK(INVISIBLECHAIN.AERWLock); - if (EndOfPAEntr (chain)) - return (FALSE); - return (TRUE); -} - -static int -legal_env (CELL *ep USES_REGS) -{ - CELL cp, ps; - PredEntry *pe; - if (!ONLOCAL (ep) || Unsigned (ep) & 3) - return (FALSE); - cp = ep[E_CP]; - if (!ONHEAP (cp)) - return (FALSE); - ps = *((CELL *) (Addr (cp) - CellSize)); - pe = (PredEntry *) (ps - sizeof (OPREG) - sizeof (Prop)); - PELOCK(70,pe); - if (!ONHEAP (pe) || Unsigned (pe) & 3 || pe->KindOfPE & 0xff00) { - UNLOCK(pe->PELock); - return (FALSE); - } - UNLOCK(pe->PELock); - return (TRUE); -} - -static int -YapPutc(FILE *f, wchar_t ch) -{ - return (putc(ch, f)); -} - -void -DumpActiveGoals ( USES_REGS1 ) -{ - /* try to dump active goals */ - CELL *ep = YENV; /* and current environment */ - choiceptr b_ptr = B; - CELL cp; - PredEntry *pe; - int first = 1; - - if (legal_env (YENV PASS_REGS) && YENV < ENV) - ep = YENV; - else if (legal_env (ENV PASS_REGS)) - ep = ENV; - while (TRUE) - { - if (!ONLOCAL (ep) || (Unsigned (ep) & (sizeof(CELL)-1))) - break; - cp = ep[E_CP]; - if (!ONHEAP (cp) || (Unsigned (cp) & (sizeof(CELL)-1))) - break; - pe = EnvPreg((yamop *)cp); - if (!ONHEAP (pe) || Unsigned (pe) & (sizeof(CELL)-1)) - break; - PELOCK(71,pe); - if (pe->KindOfPE & 0xff00) { - UNLOCK(pe->PELock); - break; - } - if (pe->PredFlags & (CompiledPredFlag | DynamicPredFlag)) - { - Functor f; - Term mod = TermProlog; - - UNLOCK(pe->PELock); - f = pe->FunctorOfPred; - if (pe->KindOfPE && hidden (NameOfFunctor (f))) - goto next; - if (first++ == 1) - fprintf(stderr,"Active ancestors:\n"); - if (pe->ModuleOfPred) mod = pe->ModuleOfPred; - Yap_DebugPlWrite (mod); - YapPutc (stderr,':'); - if (pe->ArityOfPE == 0) { - Yap_DebugPlWrite (MkAtomTerm ((Atom)f)); - } else { - Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor (f))); - YapPutc (stderr,'/'); - Yap_DebugPlWrite (MkIntTerm (ArityOfFunctor (f))); - } - YapPutc (stderr,'\n'); - } else { - UNLOCK(pe->PELock); - } - next: - ep = (CELL *) ep[E_E]; - } - first = 1; - fprintf(stderr,"Active Choice-Points:\n"); - while (TRUE) - { - PredEntry *pe; - op_numbers opnum; - if (!ONLOCAL (b_ptr) || b_ptr->cp_b == NULL) - break; - fprintf(stderr,"%p ", b_ptr); - pe = Yap_PredForChoicePt(b_ptr, &opnum); - if (opnum == _Nstop) { - fprintf(stderr, " ********** C-Code Interface Boundary ***********\n"); - } else { - Functor f; - Term mod = PROLOG_MODULE; - - f = pe->FunctorOfPred; - if (pe->ModuleOfPred) - mod = pe->ModuleOfPred; - else mod = TermProlog; - if (mod != TermProlog && - mod != MkAtomTerm(AtomUser) ) { - Yap_DebugPlWrite (mod); - YapPutc (stderr,':'); - } - if (mod == IDB_MODULE) { - if (pe->PredFlags & NumberDBPredFlag) { - Int id = pe->src.IndxId; - Yap_DebugPlWrite(MkIntegerTerm(id)); - } else if (pe->PredFlags & AtomDBPredFlag) { - Atom At = (Atom)pe->FunctorOfPred; - Yap_DebugPlWrite(MkAtomTerm(At)); - } else { - Functor f = pe->FunctorOfPred; - Atom At = NameOfFunctor(f); - arity_t arity = ArityOfFunctor(f); - int i; - - Yap_DebugPlWrite(MkAtomTerm(At)); - YapPutc (stderr,'('); - for (i= 0; i < arity; i++) { - if (i > 0) YapPutc (stderr,','); - YapPutc (stderr,'_'); - } - YapPutc (stderr,')'); - } - YapPutc (stderr,'('); - Yap_DebugPlWrite(b_ptr->cp_a2); - YapPutc (stderr,')'); - } else if (pe->ArityOfPE == 0) { - Yap_DebugPlWrite (MkAtomTerm ((Atom)f)); - } else { - Int i = 0, arity = pe->ArityOfPE; - if (opnum == _or_last|| - opnum == _or_else) { - Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor (f))); - YapPutc (stderr,'('); - for (i= 0; i < arity; i++) { - if (i > 0) YapPutc (stderr,','); - YapPutc(stderr, '_'); - } - Yap_DebugErrorPuts (") :- ... ( _ ; _ "); - } else { - Term *args = &(b_ptr->cp_a1); - Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor (f))); - YapPutc (stderr,'('); - for (i= 0; i < arity; i++) { - if (i > 0) YapPutc (stderr,','); - Yap_DebugPlWrite(args[i]); - } - } - YapPutc (stderr,')'); - } - YapPutc (stderr,'\n'); - } - b_ptr = b_ptr->cp_b; - } -} - - -static void -detect_bug_location(yamop *yap_pc, find_pred_type where_from, char *tp, int psize) -{ - Atom pred_name; - UInt pred_arity; - Term pred_module; - Int cl; - - tp[0] = '\0'; - if ((cl = Yap_PredForCode(yap_pc, where_from, &pred_name, &pred_arity, &pred_module)) - == 0) { - /* system predicate */ -#if HAVE_SNPRINTF - snprintf(tp, psize, "%s", - "meta-call"); -#else - sprintf(tp, "%s", - "meta-call"); -#endif - } else if (pred_module == 0) { - /* don't give info on system predicates */ -#if HAVE_SNPRINTF - snprintf(tp, psize, "prolog:%s/%lu", - RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); -#else - sprintf(tp, "in prolog:%s/%lu", - RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); -#endif - } else if (cl < 0) { -#if HAVE_SNPRINTF - snprintf(tp, psize, "%s:%s/%lu", - RepAtom(AtomOfTerm(pred_module))->StrOfAE, - RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); -#else - sprintf(tp, "%s:%s/%lu", - RepAtom(AtomOfTerm(pred_module))->StrOfAE, - RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); -#endif - } else { -#if HAVE_SNPRINTF - snprintf(tp, psize, "%s:%s/%lu at clause %lu ", - RepAtom(AtomOfTerm(pred_module))->StrOfAE, - RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity, (unsigned long int)cl); -#else - sprintf(tp, "%s:%s/%lu at clause %lu", - RepAtom(AtomOfTerm(pred_module))->StrOfAE, - RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity, (unsigned long int)cl); -#endif - } -} - -static bool -handled_exception( USES_REGS1 ) -{ - yamop *pos = NEXTOP(PredDollarCatch->cs.p_code.TrueCodeOfPred,l); - bool found_handler = false; - choiceptr gc_b; - - gc_b = B; - while (gc_b) { - yamop *ap = gc_b->cp_ap; - if (ap == NOCODE) { - /* C-code: let they deal with that */ - return false; - } else if (ap == pos) { - if (found_handler) - return TRUE; /* we have two handlers */ - found_handler = true; - } - gc_b = gc_b->cp_b; - } - /* handled by Top c-code? */ - return !found_handler; -} - - -static void -dump_stack( void ) -{ +static void error_exit_yap(int value) { CACHE_REGS - choiceptr b_ptr = B; - CELL *env_ptr = ENV; - char tp[256]; - yamop *ipc = CP; - int max_count = 200; - - /* check if handled */ - if (handled_exception( PASS_REGS1 )) - return; -#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); - fprintf(stderr,"%% YAP mode: %ux\n",(unsigned int)LOCAL_PrologMode); - if (LOCAL_ErrorMessage) - fprintf(stderr,"%% LOCAL_ErrorMessage: %s\n",LOCAL_ErrorMessage); -#endif - if (HR > ASP || HR > LCL0) { - 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", HeapTop, LOCAL_GlobalBase); - } else { -#if !USE_SYSTEM_MALLOC - fprintf (stderr,"%ldKB of Code Space (%p--%p)\n",(long int)((CELL)HeapTop-(CELL)Yap_HeapBase)/1024,Yap_HeapBase,HeapTop); -#if USE_DL_MALLOC - if (Yap_NOfMemoryHoles) { - UInt i; + if (!(LOCAL_PrologMode & BootMode)) { - for (i=0; i < Yap_NOfMemoryHoles; i++) - fprintf(stderr," Current hole: %p--%p\n", - Yap_MemoryHoles[i].start, - Yap_MemoryHoles[i].end); - } -#endif -#endif - detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256); - fprintf (stderr,"%%\n%% PC: %s\n",(char *)HR); - detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256); - fprintf (stderr,"%% Continuation: %s\n",(char *)HR); - 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",(unsigned long int)(sizeof(CELL)*(LCL0-ASP))/1024,ASP,LCL0); - 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", (unsigned long int)LOCAL_GcCalls); -#if LOW_LEVEL_TRACER - { - extern long long vsc_count; - - if (vsc_count) { -#if _WIN32 - fprintf(stderr,"Trace Counter at %I64d\n",vsc_count); -#else - fprintf(stderr,"Trace Counter at %lld\n",vsc_count); -#endif - } - } -#endif - 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) { - detect_bug_location(ipc, FIND_PRED_FROM_ENV, tp, 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); - } else { - fprintf(stderr,"%% %s\n", tp); - } - if (!max_count--) { - fprintf(stderr,"%% .....\n"); - return; - } - ipc = (yamop *)(env_ptr[E_CP]); - env_ptr = (CELL *)(env_ptr[E_E]); - } - if (b_ptr) { - if (!max_count--) { - fprintf(stderr,"%% .....\n"); - return; - } - if (b_ptr->cp_ap && /* tabling */ - b_ptr->cp_ap->opc != Yap_opcode(_or_else) && - b_ptr->cp_ap->opc != Yap_opcode(_or_last) && - b_ptr->cp_ap->opc != Yap_opcode(_Nstop)) { - /* we can safely ignore ; because there is always an upper env */ - detect_bug_location(b_ptr->cp_ap, FIND_PRED_FROM_CP, tp, 256); - 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); - } - b_ptr = b_ptr->cp_b; - } - } - } -} - - -static void -error_exit_yap (int value) -{ - CACHE_REGS - if (!(LOCAL_PrologMode & BootMode)) { - dump_stack( ); #if DEBUG #endif - } + } fprintf(stderr, "\n Exiting ....\n"); Yap_exit(value); } - -#ifdef DEBUG - -void -Yap_bug_location(yamop *pc) -{ - CACHE_REGS - detect_bug_location(pc, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256); - fprintf(stderr,"%s\n",(char *)HR); - dump_stack( ); -} - -#endif - /* This needs to be a static because I can't trust the stack (WIN32), and I can't trust the Yap stacks (error) */ #define YAP_BUF_SIZE 512 static char tmpbuf[YAP_BUF_SIZE]; -yamop * -Yap_NilError(yap_error_number type, const char *format,...) -{ - va_list ap; - yamop *res; +// error classes: based on OSI errors. +// +// - The extra argument says whether there different instances +// +// - Events are treated within the same pipeline as errors. +// - va_start (ap, format); - /* now build the error string */ - res = Yap_Error(type, TermNil, format, ap); - va_end (ap); +#undef BEGIN_ERROR_CLASSES +#undef ECLASS +#undef END_ERROR_CLASSES +#undef BEGIN_ERRORS +#undef E0 +#undef E +#undef E2 +#undef END_ERRORS - return res; -} +#define BEGIN_ERROR_CLASSES() \ + static Term mkerrorct(yap_error_class_number c, Term *ts) { \ + switch (c) { +#define ECLASS(CL, A, B) \ + case CL: \ + if (A == 0) \ + return MkAtomTerm(Yap_LookupAtom(A)); \ + else { \ + return Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom(A), B), B, ts); \ + } -yamop * -Yap_Error(yap_error_number type, Term where, const char *format,...) -{ +#define END_ERROR_CLASSES() \ + } \ + } + +#define BEGIN_ERRORS() \ + static Term mkerrort(yap_error_number e, Term *ts) { \ + switch (e) { + +#define E0(A, B) \ + case A: \ + return mkerrorct(B, ts); + +#define E(A, B, C) \ + case A: \ + ts -= 1; \ + ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \ + return mkerrorct(B, ts); + +#define E2(A, B, C, D) \ + case A: \ + ts -= 2; \ + ts[0] = MkAtomTerm(Yap_LookupAtom(C)); \ + ts[1] = MkAtomTerm(Yap_LookupAtom(D)); \ + return mkerrorct(B, ts); + +#define END_ERRORS() \ + } \ + } + +#include "YapErrors.h" + +/** + * @brief Yap_Error__ + * This function handles errors in the C code. Check errors.yap for the + *corresponding Prolog code. + * + * @param file C source + * @param function C function + * @param lineno C exact line + * @param type the error ID (in YAP this is a single integer) + * @param where the culprit + * @return usually FAILCODE + * + * In a good day, the error handler's job is to generate a throw. This includes: + * - constructing an ISO style error term; + * - constructing a list with all available info on the bug + * - generating the throw + * - forcing backtracking in order to restart. + * + * In a bad day, it has to deal with OOM, abort, and errors within errorts. + * + * The list includes the following options: + * + c=c(file, line, function): where the bug was detected; + * + * + p=p(mod, name, arity, file, line): the prolog procedure that caused the bug, + *and optionally, + * + * + g=g(Goal): the goal that created this mess + * + * + i=i(Comment): an user-written comment on this bug. + */ +yamop *Yap_Error__(const char *file, const char *function, int lineno, + yap_error_number type, Term where, ...) { CACHE_REGS - va_list ap; + va_list ap; CELL nt[3]; Functor fun; - int serious; - int psize = YAP_BUF_SIZE; + bool serious; + Term tf, error_t; + /* disallow recursive error handling */ + if (LOCAL_PrologMode & InErrorMode) { + fprintf(stderr, "%% ERROR WITHIN ERROR %d: %s\n", LOCAL_CurrentError, + tmpbuf); + Yap_RestartYap(1); + } + LOCAL_PrologMode |= InErrorMode; LOCAL_Error_TYPE = YAP_NO_ERROR; Yap_ClearExs(); if (where == 0L) where = TermNil; + // first, obtain current location + sprintf(LOCAL_FileNameBuf, "%s:%d in C-function %s ", file, lineno, function); + tf = MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)); #if DEBUG_STRICT - if (Yap_heap_regs && !(LOCAL_PrologMode & BootMode)) - fprintf(stderr,"***** Processing Error %d (%lx,%x) %s***\n", type, (unsigned long int)LOCAL_Signals,LOCAL_PrologMode,format); + if (Yap_heap_regs && !(LOCAL_PrologMode & BootMode)) + fprintf(stderr, "***** Processing Error %d (%lx,%x) %s***\n", type, + (unsigned long int)LOCAL_Signals, LOCAL_PrologMode, format); else - fprintf(stderr,"***** Processing Error %d (%x) %s***\n", type,LOCAL_PrologMode,format); + fprintf(stderr, "***** Processing Error %d (%x) %s***\n", type, + LOCAL_PrologMode, format); #endif - if (type == INTERRUPT_ERROR) { - fprintf(stderr,"%% YAP exiting: cannot handle signal %d\n", - (int)IntOfTerm(where)); + if (type == INTERRUPT_EVENT) { + fprintf(stderr, "%% YAP exiting: cannot handle signal %d\n", + (int)IntOfTerm(where)); Yap_exit(1); } - /* disallow recursive error handling */ - if (LOCAL_PrologMode & InErrorMode) { - /* error within error */ - va_start (ap, format); - /* now build the error string */ - if (format != NULL) { -#if HAVE_VSNPRINTF - (void) vsnprintf(tmpbuf, YAP_BUF_SIZE, format, ap); -#else - (void) vsprintf(tmpbuf, format, ap); -#endif - } else { - tmpbuf[0] = '\0'; - } - va_end (ap); - fprintf(stderr,"%% ERROR WITHIN ERROR %d: %s\n", LOCAL_CurrentError, tmpbuf); - Yap_RestartYap( 1 ); - } if (LOCAL_within_print_message) { /* error within error */ - va_start (ap, format); - /* now build the error string */ - if (format != NULL) { -#if HAVE_VSNPRINTF - (void) vsnprintf(tmpbuf, YAP_BUF_SIZE, format, ap); -#else - (void) vsprintf(tmpbuf, format, ap); -#endif - } else { - tmpbuf[0] = '\0'; - } - va_end (ap); - fprintf(stderr,"%% ERROR WITHIN WARNING %d: %s\n", LOCAL_CurrentError, tmpbuf); - Yap_exit( 1 ); + fprintf(stderr, "%% ERROR WITHIN WARNING %d: %s\n", LOCAL_CurrentError, + tmpbuf); + Yap_exit(1); } /* must do this here */ - if (type == FATAL_ERROR - || type == INTERNAL_ERROR -#if USE_SYSTEM_MALLOC - || !Yap_heap_regs + if (type == (SYSTEM_ERROR_FATAL || type == SYSTEM_ERROR_INTERNAL +#if USE_SYSTEM_MALLOC + || !Yap_heap_regs #else - || !Yap_HeapBase + || !Yap_HeapBase #endif - ) { - if (format != NULL) { - va_start (ap, format); + )) { + { + va_start(ap, where); + char *format = NULL; + format = va_arg(ap, char *); /* now build the error string */ -#if HAVE_VSNPRINTF - (void) vsnprintf(tmpbuf, YAP_BUF_SIZE, format, ap); + if (format) { +#if HAVE_VSNPRINTF + (void)vsnprintf(tmpbuf, YAP_BUF_SIZE, format, ap); #else - (void) vsprintf(tmpbuf, format, ap); + (void)vsprintf(tmpbuf, format, ap); #endif - va_end (ap); - } else { - tmpbuf[0] = '\0'; + } else { + tmpbuf[0] = '\0'; + } + va_end(ap); } if (LOCAL_PrologMode == UserCCallMode) { - fprintf(stderr,"%%\n%%\n"); - fprintf(stderr,"%% YAP OOOPS in USER C-CODE: %s.\n",tmpbuf); - fprintf(stderr,"%%\n%%\n"); + fprintf(stderr, "%%\n%%\n"); + fprintf(stderr, "%% YAP OOOPS in USER C-CODE: %s.\n", tmpbuf); + fprintf(stderr, "%%\n%%\n"); } else { - fprintf(stderr,"%%\n%%\n"); - fprintf(stderr,"%% YAP OOOPS: %s.\n",tmpbuf); - fprintf(stderr,"%%\n%%\n"); + fprintf(stderr, "%%\n%%\n"); + fprintf(stderr, "%% YAP OOOPS: %s.\n", tmpbuf); + fprintf(stderr, "%%\n%%\n"); } - detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256); - fprintf (stderr,"%%\n%% PC: %s\n",(char *)HR); - detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256); - fprintf (stderr,"%% Continuation: %s\n",(char *)HR); - error_exit_yap (1); + Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256); + fprintf(stderr, "%%\n%% PC: %s\n", (char *)HR); + Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256); + fprintf(stderr, "%% Continuation: %s\n", (char *)HR); + error_exit_yap(1); } if (P == (yamop *)(FAILCODE)) - return P; - /* PURE_ABORT may not have set where correctly, BootMode may not have the data terms ready */ - if (type == PURE_ABORT || LOCAL_PrologMode & BootMode) { + return P; + /* PURE_ABORT may not have set where correctly, BootMode may not have the data + * terms ready */ + if (type == ABORT_EVENT || LOCAL_PrologMode & BootMode) { where = TermNil; LOCAL_PrologMode &= ~AbortMode; LOCAL_CurrentError = type; @@ -743,7 +416,7 @@ Yap_Error(yap_error_number type, Term where, const char *format,...) Yap_signal(YAP_FAIL_SIGNAL); P = FAILCODE; } else { - if (IsVarTerm(where)) { + if (IsVarTerm(where)) { /* we must be careful someone gave us a copy to a local variable */ Term t = MkVarTerm(); Yap_unify(t, where); @@ -754,58 +427,56 @@ Yap_Error(yap_error_number type, Term where, const char *format,...) LOCAL_CurrentError = type; LOCAL_PrologMode |= InErrorMode; if (!(where = Yap_CopyTerm(where))) { - where = TermNil; + where = TermNil; } } - va_start (ap, format); - /* now build the error string */ - if (format != NULL) - { -#if HAVE_VSNPRINTF - (void) vsnprintf(tmpbuf, YAP_BUF_SIZE, format, ap); + { + char *format; + va_start(ap, where); + format = va_arg(ap, char *); + if (format != NULL) { +#if HAVE_VSNPRINTF + (void)vsnprintf(tmpbuf, YAP_BUF_SIZE, format, ap); #else - (void) vsprintf(tmpbuf, format, ap); + (void)vsprintf(tmpbuf, format, ap); #endif - } - else - tmpbuf[0] = '\0'; - va_end (ap); + } else + tmpbuf[0] = '\0'; + va_end(ap); + } if (LOCAL_PrologMode & BootMode) { /* crash in flames! */ - fprintf(stderr,"%% YAP Fatal Error: %s exiting....\n",tmpbuf); - error_exit_yap (1); + fprintf(stderr, "%% YAP Fatal Error: %s exiting....\n", tmpbuf); + error_exit_yap(1); } #ifdef DEBUG // DumpActiveGoals( USES_REGS1 ); #endif /* DEBUG */ switch (type) { - case INTERNAL_ERROR: - { - fprintf(stderr,"%% Internal YAP Error: %s exiting....\n",tmpbuf); - serious = TRUE; - if (LOCAL_PrologMode & BootMode) { - fprintf(stderr,"%% YAP crashed while booting %s\n",tmpbuf); - } else { - detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, tmpbuf, YAP_BUF_SIZE); - fprintf(stderr,"%% Bug found while executing %s\n",tmpbuf); - } - error_exit_yap (1); + case SYSTEM_ERROR_INTERNAL: { + fprintf(stderr, "%% Internal YAP Error: %s exiting....\n", tmpbuf); + serious = TRUE; + if (LOCAL_PrologMode & BootMode) { + fprintf(stderr, "%% YAP crashed while booting %s\n", tmpbuf); + } else { + Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, tmpbuf, YAP_BUF_SIZE); + fprintf(stderr, "%% Bug found while executing %s\n", tmpbuf); } - case FATAL_ERROR: - { - fprintf(stderr,"%% Fatal YAP Error: %s exiting....\n",tmpbuf); - error_exit_yap (1); - } - case INTERRUPT_ERROR: - { - error_exit_yap (1); - } - case PURE_ABORT: + error_exit_yap(1); + } + case SYSTEM_ERROR_FATAL: { + fprintf(stderr, "%% Fatal YAP Error: %s exiting....\n", tmpbuf); + error_exit_yap(1); + } + case INTERRUPT_EVENT: { + error_exit_yap(1); + } + case ABORT_EVENT: nt[0] = MkAtomTerm(AtomDAbort); fun = FunctorVar; serious = TRUE; break; - case CALL_COUNTER_UNDERFLOW: + case CALL_COUNTER_UNDERFLOW_EVENT: /* Do a long jump */ LOCAL_ReductionsCounterOn = FALSE; LOCAL_PredEntriesCounterOn = FALSE; @@ -813,8 +484,8 @@ Yap_Error(yap_error_number type, Term where, const char *format,...) Yap_JumpToEnv(MkAtomTerm(AtomCallCounter)); P = (yamop *)FAILCODE; LOCAL_PrologMode &= ~InErrorMode; - return(P); - case PRED_ENTRY_COUNTER_UNDERFLOW: + return (P); + case PRED_ENTRY_COUNTER_UNDERFLOW_EVENT: /* Do a long jump */ LOCAL_ReductionsCounterOn = FALSE; LOCAL_PredEntriesCounterOn = FALSE; @@ -822,8 +493,8 @@ Yap_Error(yap_error_number type, Term where, const char *format,...) Yap_JumpToEnv(MkAtomTerm(AtomCallAndRetryCounter)); P = (yamop *)FAILCODE; LOCAL_PrologMode &= ~InErrorMode; - return(P); - case RETRY_COUNTER_UNDERFLOW: + return (P); + case RETRY_COUNTER_UNDERFLOW_EVENT: /* Do a long jump */ LOCAL_ReductionsCounterOn = FALSE; LOCAL_PredEntriesCounterOn = FALSE; @@ -831,1359 +502,30 @@ Yap_Error(yap_error_number type, Term where, const char *format,...) Yap_JumpToEnv(MkAtomTerm(AtomRetryCounter)); P = (yamop *)FAILCODE; LOCAL_PrologMode &= ~InErrorMode; - return(P); - case CONSISTENCY_ERROR: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = where; - nt[0] = Yap_MkApplTerm(FunctorConsistencyError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_ARRAY_OVERFLOW: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomArrayOverflow); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_FILE_ERRORS: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = TermArrayType; - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_FILE_TYPE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = TermFileType; - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_IO_MODE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = TermIOMode; - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_MUTABLE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomMutable); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_NON_EMPTY_LIST: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomNonEmptyList); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_NOT_LESS_THAN_ZERO: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomNotLessThanZero); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_NOT_NL: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomNotNewline); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_NOT_ZERO: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomNotZero); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_OUT_OF_RANGE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomOutOfRange); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_OPERATOR_PRIORITY: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomOperatorPriority); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_OPERATOR_SPECIFIER: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomOperatorSpecifier); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_PROLOG_FLAG: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(Yap_LookupAtom("prolog_flag")); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_RADIX: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomRadix); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomShiftCountOverflow); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_SOLUTIONS: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = TermSolutions; - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_SOURCE_SINK: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomSourceSink); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_STREAM: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomVStream); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_STREAM_OR_ALIAS: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomStreamOrAlias); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_STREAM_ENCODING: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomEncoding); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_STREAM_POSITION: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomStreamPosition); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_SYNTAX_ERROR_HANDLER: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomSyntaxErrorHandler); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case DOMAIN_ERROR_TIMEOUT_SPEC: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomTimeOutSpec); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EXISTENCE_ERROR_SOURCE_SINK: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomSourceSink); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorExistenceError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EXISTENCE_ERROR_ARRAY: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomArray); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorExistenceError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EXISTENCE_ERROR_KEY: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomKey); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorExistenceError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EXISTENCE_ERROR_STREAM: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomVStream); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorExistenceError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EXISTENCE_ERROR_MUTEX: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomMutex); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorExistenceError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EXISTENCE_ERROR_VARIABLE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomVariable); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorExistenceError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EVALUATION_ERROR_FLOAT_OVERFLOW: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomFloatOverflow); - nt[0] = Yap_MkApplTerm(FunctorEvaluationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EVALUATION_ERROR_INT_OVERFLOW: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomIntOverflow); - nt[0] = Yap_MkApplTerm(FunctorEvaluationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EVALUATION_ERROR_UNDEFINED: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomUndefined); - nt[0] = Yap_MkApplTerm(FunctorEvaluationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EVALUATION_ERROR_FLOAT_UNDERFLOW: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomFloatUnderflow); - nt[0] = Yap_MkApplTerm(FunctorEvaluationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EVALUATION_ERROR_UNDERFLOW: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomUnderflow); - nt[0] = Yap_MkApplTerm(FunctorEvaluationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case EVALUATION_ERROR_ZERO_DIVISOR: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomZeroDivisor); - nt[0] = Yap_MkApplTerm(FunctorEvaluationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case INSTANTIATION_ERROR: - { - int i; - - i = strlen(tmpbuf); - nt[0] = MkAtomTerm(AtomInstantiationError); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case OPERATING_SYSTEM_ERROR: - { - int i; - - i = strlen(tmpbuf); - nt[0] = MkAtomTerm(AtomOperatingSystemError); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case OUT_OF_HEAP_ERROR: - { - int i; - Term ti[1]; - - dump_stack(); - ti[0] = MkAtomTerm(AtomCodeSpace); - i = strlen(tmpbuf); - nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case OUT_OF_STACK_ERROR: - { - int i; - Term ti[1]; - - dump_stack( ); - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomStack); - nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case OUT_OF_ATTVARS_ERROR: - { - int i; - Term ti[1]; - - dump_stack( ); - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomAttributes); - nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case OUT_OF_AUXSPACE_ERROR: - { - int i; - Term ti[1]; - - dump_stack( ); - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomUnificationStack); - nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case OUT_OF_TRAIL_ERROR: - { - int i; - Term ti[1]; - - dump_stack( ); - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomTrail); - nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_ACCESS_PRIVATE_PROCEDURE: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomAccess); - ti[1] = MkAtomTerm(AtomPrivateProcedure); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_CREATE_ARRAY: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomCreate); - ti[1] = MkAtomTerm(AtomArray); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_CREATE_OPERATOR: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomCreate); - ti[1] = MkAtomTerm(AtomOperator); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_INPUT_BINARY_STREAM: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomInput); - ti[1] = MkAtomTerm(AtomBinaryStream); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomInput); - ti[1] = MkAtomTerm(AtomPastEndOfStream); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_INPUT_STREAM: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomInput); - ti[1] = MkAtomTerm(AtomVStream); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_INPUT_TEXT_STREAM: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomInput); - ti[1] = MkAtomTerm(AtomTextStream); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomModify); - ti[1] = MkAtomTerm(AtomStaticProcedure); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomNew); - ti[1] = MkAtomTerm(AtomAlias); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_OPEN_SOURCE_SINK: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomOpen); - ti[1] = MkAtomTerm(AtomSourceSink); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_OUTPUT_BINARY_STREAM: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomOutput); - ti[1] = MkAtomTerm(AtomBinaryStream); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_OUTPUT_STREAM: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomOutput); - ti[1] = MkAtomTerm(AtomVStream); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_OUTPUT_TEXT_STREAM: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomOutput); - ti[1] = MkAtomTerm(AtomTextStream); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_REPOSITION_STREAM: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomReposition); - ti[1] = MkAtomTerm(AtomVStream); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case PERMISSION_ERROR_RESIZE_ARRAY: - { - int i; - Term ti[3]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomResize); - ti[1] = MkAtomTerm(AtomArray); - ti[2] = where; - nt[0] = Yap_MkApplTerm(FunctorPermissionError, 3, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case REPRESENTATION_ERROR_CHARACTER: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomCharacter); - nt[0] = Yap_MkApplTerm(FunctorRepresentationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case REPRESENTATION_ERROR_CHARACTER_CODE: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomCharacterCode); - nt[0] = Yap_MkApplTerm(FunctorRepresentationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case REPRESENTATION_ERROR_INT: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomInt); - nt[0] = Yap_MkApplTerm(FunctorRepresentationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case REPRESENTATION_ERROR_MAX_ARITY: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomMaxArity); - nt[0] = Yap_MkApplTerm(FunctorRepresentationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case REPRESENTATION_ERROR_VARIABLE: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomVariable); - nt[0] = Yap_MkApplTerm(FunctorRepresentationError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case RESOURCE_ERROR_MAX_STREAMS: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomStreams); - nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case RESOURCE_ERROR_STACK: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomStack); - nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case RESOURCE_ERROR_HUGE_INT: - { - int i; - Term ti[1]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomHugeInt); - nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case SYNTAX_ERROR: - { - int i; - - i = strlen(tmpbuf); - psize -= i; - fun = FunctorSyntaxError; - serious = false; - } - break; - case SAVED_STATE_ERROR: - { - int i; - - i = strlen(tmpbuf); - nt[0] = MkAtomTerm(AtomSystemError); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case SYSTEM_ERROR: - { - int i; - - i = strlen(tmpbuf); - nt[0] = MkAtomTerm(AtomSystemError); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case INTERNAL_COMPILER_ERROR: - { - int i; - - i = strlen(tmpbuf); - nt[0] = MkAtomTerm(AtomInternalCompilerError); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_ARRAY: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomArray); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_ATOM: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomAtom); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_ATOMIC: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomAtomic); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_BIGNUM: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomBigNum); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_BYTE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomByte); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_CALLABLE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomCallable); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_CHAR: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomChar); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_CHARACTER: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomCharacter); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_COMPOUND: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomCompound); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_DBREF: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomDBReference); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_DBTERM: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomDBTerm); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_EVALUABLE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomEvaluable); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_FLOAT: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomFloat); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_INTEGER: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomInteger); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_KEY: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomKey); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_LIST: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomList); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_NUMBER: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomNumber); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_PARAMETER: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomParameter); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_PREDICATE_INDICATOR: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomPredicateIndicator); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_PTR: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomPointer); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_REFERENCE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomDBReference); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_STRING: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomString); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_TEXT: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomText); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_UBYTE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomUnsignedByte); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_UCHAR: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomUnsignedChar); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - case TYPE_ERROR_VARIABLE: - { - int i; - Term ti[2]; - - i = strlen(tmpbuf); - ti[0] = MkAtomTerm(AtomVariable); - ti[1] = where; - nt[0] = Yap_MkApplTerm(FunctorTypeError, 2, ti); - psize -= i; - fun = FunctorError; - serious = TRUE; - } - break; - default: - { - int i; - - i = strlen(tmpbuf); - nt[0] = MkAtomTerm(AtomSystemError); - psize -= i; - fun = FunctorError; - serious = TRUE; - } + return (P); + default: { + Term ts[3]; + ts[2] = where; + nt[0] = mkerrort(type, ts + 2); } - if (type != PURE_ABORT) { + } + if (type != ABORT_EVENT) { /* This is used by some complex procedures to detect there was an error */ if (IsAtomTerm(nt[0])) { - strncpy(LOCAL_ErrorSay, (char *)RepAtom(AtomOfTerm(nt[0]))->StrOfAE, MAX_ERROR_MSG_SIZ\ -E); + strncpy(LOCAL_ErrorSay, (char *)RepAtom(AtomOfTerm(nt[0]))->StrOfAE, + MAX_ERROR_MSG_SIZE); LOCAL_ErrorMessage = LOCAL_ErrorSay; } else { - strncpy(LOCAL_ErrorSay, (char *)RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE,\ - MAX_ERROR_MSG_SIZE); + strncpy(LOCAL_ErrorSay, + (char *)RepAtom(NameOfFunctor(FunctorOfTerm(nt[0])))->StrOfAE, + MAX_ERROR_MSG_SIZE); LOCAL_ErrorMessage = LOCAL_ErrorSay; } } switch (type) { - case OUT_OF_HEAP_ERROR: - case OUT_OF_STACK_ERROR: - case OUT_OF_TRAIL_ERROR: + case RESOURCE_ERROR_HEAP: + case RESOURCE_ERROR_STACK: + case RESOURCE_ERROR_TRAIL: nt[1] = MkAtomTerm(Yap_LookupAtom(tmpbuf)); break; default: @@ -2195,44 +537,48 @@ E); LOCAL_Error_Size = 0L; } nt[1] = MkPairTerm(MkAtomTerm(Yap_LookupAtom(tmpbuf)), - MkPairTerm(stack_dump, TermNil)); + MkPairTerm(stack_dump, TermNil)); if (type == SYNTAX_ERROR) { nt[1] = MkPairTerm(where, nt[1]); } } } - if (serious) { - /* disable active signals at this point */ - LOCAL_Signals = 0; - CalculateStackGap( PASS_REGS1 ); - LOCAL_PrologMode &= ~InErrorMode; - /* we might be in the middle of a critical region */ - if (LOCAL_InterruptsDisabled) { - LOCAL_InterruptsDisabled = 0; - LOCAL_UncaughtThrow = TRUE; - Yap_RestartYap( 1 ); - } + /* disable active signals at this point */ + LOCAL_Signals = 0; + CalculateStackGap(PASS_REGS1); + LOCAL_PrologMode &= ~InErrorMode; + /* we might be in the middle of a critical region */ + if (LOCAL_InterruptsDisabled) { + LOCAL_InterruptsDisabled = 0; + LOCAL_UncaughtThrow = TRUE; + Yap_RestartYap(1); + } #if DEBUG - // DumpActiveGoals( PASS_REGS1 ); + // DumpActiveGoals( PASS_REGS1 ); #endif - /* wait if we we are in user code, - it's up to her to decide */ - - if (LOCAL_PrologMode & UserCCallMode) { - if (!(EX = Yap_StoreTermInDB(Yap_MkApplTerm(fun, 2, nt), 0))) { - /* fat chance */ - Yap_RestartYap( 1 ); - } - } else { - if (type == PURE_ABORT) { - Yap_JumpToEnv(MkAtomTerm(AtomDAbort)); - } else - Yap_JumpToEnv(Yap_MkApplTerm(fun, 2, nt)); - P = (yamop *)FAILCODE; + /* wait if we we are in user code, + it's up to her to decide */ + fun = FunctorError; + if (LOCAL_PrologMode & UserCCallMode) { + error_t = Yap_MkApplTerm(fun, 2, nt); + if (!(EX = Yap_StoreTermInDB(error_t, 2))) { + /* fat chance */ + Yap_RestartYap(1); } } else { - LOCAL_PrologMode &= ~InErrorMode; + if (type == ABORT_EVENT) { + error_t = MkAtomTerm(AtomDAbort); + } else { + error_t = Yap_MkApplTerm(fun, 2, nt); + + } + Yap_JumpToEnv(error_t); + P = (yamop *)FAILCODE; } + + LOCAL_PrologMode &= ~InErrorMode; return P; + } + diff --git a/C/exec.c b/C/exec.c index 9b2ba813f..0040be005 100755 --- a/C/exec.c +++ b/C/exec.c @@ -424,7 +424,7 @@ EnterCreepMode(Term t, Term mod USES_REGS) { if (Yap_get_signal( YAP_CDOVF_SIGNAL ) ) { ARG1 = t; if (!Yap_locked_growheap(FALSE, 0, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap at meta-call"); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "YAP failed to grow heap at meta-call"); } if (!Yap_has_a_signal()) { return do_execute(ARG1, mod PASS_REGS); @@ -1361,7 +1361,7 @@ Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) } return(FALSE); } else { - Yap_Error(SYSTEM_ERROR,TermNil,"emulator crashed"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"emulator crashed"); return(FALSE); } } @@ -1489,7 +1489,7 @@ restart_runtopgoal: #if !USE_SYSTEM_MALLOC if (LOCAL_TrailTop - HeapTop < 2048) { LOCAL_PrologMode = BootMode; - Yap_Error(OUT_OF_TRAIL_ERROR,TermNil, + Yap_Error(RESOURCE_ERROR_TRAIL,TermNil, "unable to boot because of too little Trail space"); } #endif @@ -1922,16 +1922,16 @@ Yap_GetException(void) do { t = Yap_PopTermFromDB(LOCAL_BallTerm); if (t == 0) { - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, LOCAL_ErrorMessage); return FALSE; } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growstack(LOCAL_BallTerm->NOfCells*CellSize)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } diff --git a/C/exo.c b/C/exo.c index d518bef7b..9bbe6ad82 100755 --- a/C/exo.c +++ b/C/exo.c @@ -402,7 +402,7 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count) save_machine_regs(); LOCAL_Error_Size = 3*ncls*sizeof(CELL); LOCAL_ErrorMessage = "not enough space to index"; - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return NULL; } i->is_key = FALSE; @@ -422,7 +422,7 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count) LOCAL_Error_Size = dsz; LOCAL_ErrorMessage = "not enough space to generate indices"; Yap_FreeCodeSpace((void *)i); - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return NULL; } memset(base, 0, dsz); diff --git a/C/flags.c b/C/flags.c index a29a72075..ca6384e0d 100644 --- a/C/flags.c +++ b/C/flags.c @@ -546,7 +546,7 @@ initFlag(flag_info *f, int fnum, bool global) fprop = (FlagEntry *) Yap_AllocAtomSpace(sizeof(FlagEntry)); if (fprop == NULL) { WRITE_UNLOCK(ae->ARWLock); - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"not enough space for new Flag %s", ae->StrOfAE); return; + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"not enough space for new Flag %s", ae->StrOfAE); return; } fprop->KindOfPE = FlagProperty; fprop->FlagOfVE = fnum; diff --git a/C/globals.c b/C/globals.c index 8ab5d5253..8d70e7755 100644 --- a/C/globals.c +++ b/C/globals.c @@ -199,7 +199,7 @@ NewArena(UInt size, int wid, UInt arity, CELL *where) if (where == NULL || where == HR) { while (HR+size > ASP-1024) { if (!Yap_gcl(size*sizeof(CELL), arity, ENV, P)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return TermNil; } } @@ -207,7 +207,7 @@ NewArena(UInt size, int wid, UInt arity, CELL *where) HR += size; } else { if ((new_size=Yap_InsertInGlobal(where, size*sizeof(CELL)))==0) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,"No Stack Space for Non-Backtrackable terms"); + Yap_Error(RESOURCE_ERROR_STACK,TermNil,"No Stack Space for Non-Backtrackable terms"); return TermNil; } size = new_size/sizeof(CELL); @@ -275,7 +275,7 @@ GrowArena(Term arena, CELL *pt, size_t old_size, size_t size, UInt arity USES_RE XREGS[arity+1] = arena; if (!Yap_gcl(size*sizeof(CELL), arity+1, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } arena = XREGS[arity+1]; @@ -290,7 +290,7 @@ GrowArena(Term arena, CELL *pt, size_t old_size, size_t size, UInt arity USES_RE /* try to recover some room */ if (arena == LOCAL_GlobalArena && 10*(pt-H0) > 8*(HR-H0)) { if (!Yap_gcl(size*sizeof(CELL), arity+1, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK,TermNil,LOCAL_ErrorMessage); return FALSE; } } @@ -826,13 +826,13 @@ CopyTermToArena(Term t, Term arena, bool share, bool copy_att_vars, UInt arity, if (arena == LOCAL_GlobalArena) LOCAL_GlobalArenaOverflows++; if (!GrowArena(arena, old_top, old_size, min_grow, arity+3 PASS_REGS)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return 0L; } break; default: /* temporary space overflow */ if (!Yap_ExpandPreAllocCodeSpace(0,NULL,TRUE)) { - Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, TermNil, LOCAL_ErrorMessage); return 0L; } } @@ -880,7 +880,7 @@ CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity, Term *newarena, Ter if (arena == LOCAL_GlobalArena) LOCAL_GlobalArenaOverflows++; if (!GrowArena(arena, old_top, old_size, Nar*sizeof(CELL), arity+2 PASS_REGS)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while creating large global term"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "while creating large global term"); return 0L; } } @@ -1350,7 +1350,7 @@ p_b_setval( USES_REGS1 ) return TRUE; #else WRITE_UNLOCK(ge->GRWLock); - Yap_Error(SYSTEM_ERROR,t,"update_array"); + Yap_Error(SYSTEM_ERROR_INTERNAL,t,"update_array"); return FALSE; #endif } @@ -1766,7 +1766,7 @@ p_nb_queue_enqueue( USES_REGS1 ) ARG3 = to; /* fprintf(stderr,"growing %ld cells\n",(unsigned long int)gsiz);*/ if (!GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3 PASS_REGS)) { - Yap_Error(OUT_OF_STACK_ERROR, arena, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, arena, LOCAL_ErrorMessage); return 0L; } to = ARG3; @@ -1944,7 +1944,7 @@ p_nb_heap( USES_REGS1 ) while ((heap = MkZeroApplTerm(Yap_MkFunctor(AtomHeap,2*hsize+HEAP_START+1),2*hsize+HEAP_START+1 PASS_REGS)) == TermNil) { if (!Yap_gcl((2*hsize+HEAP_START+1)*sizeof(CELL), 2, ENV, P)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } @@ -2062,7 +2062,7 @@ p_nb_heap_add_to_heap( USES_REGS1 ) extra_size = hmsize; } if ((extra_size=Yap_InsertInGlobal(top, extra_size*2*sizeof(CELL)))==0) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,"No Stack Space for Non-Backtrackable terms"); + Yap_Error(RESOURCE_ERROR_STACK,TermNil,"No Stack Space for Non-Backtrackable terms"); return FALSE; } extra_size = extra_size/(2*sizeof(CELL)); @@ -2118,7 +2118,7 @@ p_nb_heap_add_to_heap( USES_REGS1 ) } ARG3 = to; if (!GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3 PASS_REGS)) { - Yap_Error(OUT_OF_STACK_ERROR, arena, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, arena, LOCAL_ErrorMessage); return 0L; } to = ARG3; @@ -2226,7 +2226,7 @@ p_nb_beam( USES_REGS1 ) } while ((beam = MkZeroApplTerm(Yap_MkFunctor(AtomHeap,5*hsize+HEAP_START+1),5*hsize+HEAP_START+1 PASS_REGS)) == TermNil) { if (!Yap_gcl((4*hsize+HEAP_START+1)*sizeof(CELL), 2, ENV, P)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } @@ -2507,7 +2507,7 @@ p_nb_beam_add_to_beam( USES_REGS1 ) } ARG3 = to; if (!GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3 PASS_REGS)) { - Yap_Error(OUT_OF_STACK_ERROR, arena, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, arena, LOCAL_ErrorMessage); return 0L; } to = ARG3; @@ -2619,7 +2619,7 @@ p_nb_beam_keys( USES_REGS1 ) if (HR > ASP-1024) { HR = ho; if (!Yap_gcl(((ASP-HR)-1024)*sizeof(CELL), 2, ENV, P)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return TermNil; } goto restart; diff --git a/C/gprof.c b/C/gprof.c index b5d9a001e..817c6f75b 100755 --- a/C/gprof.c +++ b/C/gprof.c @@ -805,7 +805,7 @@ InitProfTree(void) reset_tree(); while (!(GLOBAL_ProfilerRoot = RBTreeCreate())) { if (!Yap_growheap(FALSE, 0, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "while initialisating profiler"); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "while initialisating profiler"); return FALSE; } } diff --git a/C/grow.c b/C/grow.c index d63c2bc8f..de7bb6edd 100755 --- a/C/grow.c +++ b/C/grow.c @@ -244,7 +244,7 @@ RestoreTrail(int worker_p USES_REGS) if (TR == aux_tr) return; if (aux_tr < TR){ - Yap_Error(SYSTEM_ERROR, TermNil, "oops"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "oops"); } Yap_NEW_MAHASH((ma_h_inner_struct *)HR PASS_REGS); while (TR != aux_tr) { @@ -594,7 +594,7 @@ AdjustGlobal(Int sz, bool thread_copying USES_REGS) CELL ar[256]; Int i,n = (f)(Yap_BlobTag(t), Yap_BlobInfo(t), ar, 256); if (n < 0) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"not enough space for slot internal variables"); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"not enough space for slot internal variables"); } for (i = 0; i< n; i++) { CELL *pt = ar+i; @@ -618,7 +618,7 @@ AdjustGlobal(Int sz, bool thread_copying USES_REGS) if ( (f2 = Yap_blob_gc_relocate_handler(t)) < 0 ) { int out = (f2)(Yap_BlobTag(t), Yap_BlobInfo(t), ar, n); if (out < 0) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"bad restore of slot internal variables"); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"bad restore of slot internal variables"); return; } } @@ -1303,7 +1303,7 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol sz = in_size; } #ifdef YAPOR - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running"); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"cannot grow Heap: more than a worker/thread running"); return FALSE; #endif if (GLOBAL_SizeOfOverflow > sz) { @@ -1482,7 +1482,7 @@ Yap_locked_growheap(bool fix_code, size_t in_size, void *cip) } } #if USE_SYSTEM_MALLOC - P = Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"malloc failed"); + P = Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"malloc failed"); res = FALSE; #else res=do_growheap(fix_code, in_size, (struct intermediates *)cip, NULL, NULL, NULL PASS_REGS); @@ -1521,12 +1521,12 @@ Yap_locked_growglobal(CELL **ptr) #if defined(YAPOR_THREADS) if (GLOBAL_number_workers != 1) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running"); + Yap_Error(RESOURCE_ERROR_STACK,TermNil,"cannot grow Global: more than a worker/thread running"); return(FALSE); } #elif defined(THREADS) if (GLOBAL_NOfThreads != 1) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running"); + Yap_Error(RESOURCE_ERROR_STACK,TermNil,"cannot grow Global: more than a worker/thread running"); return(FALSE); } #endif @@ -1882,7 +1882,7 @@ Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp, CELL ***to_visit_base) char *newb = Yap_ExpandPreAllocCodeSpace(0, NULL, FALSE); if (newb == NULL) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot allocate temporary space for unification (%p)", to_visit); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"cannot allocate temporary space for unification (%p)", to_visit); return to_visit; } /* check new size */ @@ -1890,7 +1890,7 @@ Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp, CELL ***to_visit_base) /* how much we grew */ dsz = totalsz-totalsz0; if (dsz == 0) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot allocate temporary space for unification (%p)", to_visit); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"cannot allocate temporary space for unification (%p)", to_visit); return to_visit; } /* copy whole block to end */ @@ -1962,7 +1962,7 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, bool incremental) char *oldq = (char *)REMOTE_ThreadHandle(worker_q).stack_address, *newq; if (!(newq = REMOTE_ThreadHandle(worker_q).stack_address = realloc(REMOTE_ThreadHandle(worker_q).stack_address,p_size*K1))) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot expand slave thread to match master thread"); + Yap_Error(RESOURCE_ERROR_STACK,TermNil,"cannot expand slave thread to match master thread"); } start_growth_time = Yap_cputime(); gc_verbose = Yap_is_gc_verbose(); diff --git a/C/heapgc.c b/C/heapgc.c index 298df16af..f54fa9a82 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -3975,7 +3975,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS) if (HeapTop >= LOCAL_GlobalBase - MinHeapGap) { *--ASP = (CELL)current_env; if (!Yap_locked_growheap(FALSE, MinHeapGap, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return -1; } current_env = (CELL *)*ASP; @@ -3998,7 +3998,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS) if ( !Yap_locked_growtrail(sz, FALSE) ) { - Yap_Error(OUT_OF_TRAIL_ERROR,TermNil,"out of %lB during gc", sz); + Yap_Error(RESOURCE_ERROR_TRAIL,TermNil,"out of %lB during gc", sz); return -1; } else { LOCAL_total_marked = 0; @@ -4249,7 +4249,7 @@ LeaveGCMode( USES_REGS1 ) if (LOCAL_PrologMode & AbortMode) { LOCAL_PrologMode &= ~AbortMode; /* in case someone mangles the P register */ - Yap_Error(PURE_ABORT, TermNil, "abort from console"); + Yap_Error(ABORT_EVENT, TermNil, "abort from console"); Yap_RestartYap( 1 ); } } diff --git a/C/index.c b/C/index.c index dda8c51a3..03f0511e8 100755 --- a/C/index.c +++ b/C/index.c @@ -256,7 +256,7 @@ * fix expand_index on tabled code. * * Revision 1.129 2005/05/31 02:15:53 vsc -* fix SYSTEM_ERROR messages +* fix SYSTEM_ERROR_INTERNAL messages * * Revision 1.128 2005/05/30 05:26:49 vsc * fix tabling @@ -338,7 +338,7 @@ * Handle overflows when allocating big clauses properly. * * Revision 1.108 2004/11/19 22:08:42 vsc -* replace SYSTEM_ERROR by out OUT_OF_WHATEVER_ERROR whenever appropriate. +* replace SYSTEM_ERROR_INTERNAL by out OUT_OF_WHATEVER_ERROR whenever appropriate. * * Revision 1.107 2004/11/19 17:14:14 vsc * a few fixes for 64 bit compiling. @@ -2973,7 +2973,7 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) recover_from_failed_susp_on_cls(&cint, 0); if (!Yap_gcl(LOCAL_Error_Size, ap->ArityOfPE+NSlots, ENV, next_pc)) { CleanCls(&cint); - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FAILCODE; } } else if (setjres == 2) { @@ -2981,7 +2981,7 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) LOCAL_Error_Size = recover_from_failed_susp_on_cls(&cint, LOCAL_Error_Size); if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) { CleanCls(&cint); - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return FAILCODE; } } else if (setjres == 4) { @@ -2989,14 +2989,14 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) recover_from_failed_susp_on_cls(&cint, 0); if (!Yap_growtrail(LOCAL_Error_Size, FALSE)) { CleanCls(&cint); - Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, LOCAL_ErrorMessage); return FAILCODE; } } else if (setjres != 0) { restore_machine_regs(); recover_from_failed_susp_on_cls(&cint, 0); if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); CleanCls(&cint); return FAILCODE; } @@ -3025,7 +3025,7 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) { Yap_ReleaseCMem(&cint); CleanCls(&cint); - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return NULL; } goto restart_index; @@ -3619,7 +3619,7 @@ expand_index(struct intermediates *cint) { break; case _trust: /* we should never be here */ - Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "found trust in expand_index"); + Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "found trust in expand_index"); labp = NULL; ipc = NULL; break; @@ -3889,7 +3889,7 @@ expand_index(struct intermediates *cint) { break; default: if (alt == NULL) { - Yap_Error(INTERNAL_COMPILER_ERROR,t,"unexpected instruction %d at expand_index ", op); + Yap_Error(SYSTEM_ERROR_COMPILER,t,"unexpected instruction %d at expand_index ", op); labp = NULL; ipc = NULL; } else { @@ -4130,7 +4130,7 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) { #if defined(YAPOR) || defined(THREADS) } #endif - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); CleanCls(&cint); return FAILCODE; } @@ -4163,47 +4163,8 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) { } #if DEBUG if (GLOBAL_Option['i' - 'a' + 1]) { - Term tmod = ap->ModuleOfPred; - if (!tmod) tmod = TermProlog; -#if THREADS - Yap_DebugPlWrite(MkIntegerTerm(worker_id)); - Yap_DebugPutc(stderr,' '); -#endif - Yap_DebugPutc(stderr,'>'); - Yap_DebugPutc(stderr,'\t'); - Yap_DebugPlWrite(tmod); - Yap_DebugPutc(stderr,':'); - if (ap->ModuleOfPred == IDB_MODULE) { - Term t = Deref(ARG1); - if (IsAtomTerm(t)) { - Yap_DebugPlWrite(t); - } else if (IsIntegerTerm(t)) { - Yap_DebugPlWrite(t); - } else { - Functor f = FunctorOfTerm(t); - Atom At = NameOfFunctor(f); - Yap_DebugPlWrite(MkAtomTerm(At)); - Yap_DebugPutc(stderr,'/'); - Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); - } - } else { - if (ap->ArityOfPE == 0) { - Atom At = (Atom)ap->FunctorOfPred; - Yap_DebugPlWrite(MkAtomTerm(At)); - } else { - Functor f = ap->FunctorOfPred; - Atom At = NameOfFunctor(f); - Yap_DebugPlWrite(MkAtomTerm(At)); - Yap_DebugPutc(stderr,'/'); - Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); - } + Yap_DebugWriteIndicator( ap ); } - Yap_DebugPutc(stderr,'\n'); -#if THREADS - Yap_DebugPlWrite(MkIntegerTerm(worker_id)); - Yap_DebugPutc(stderr,' '); -#endif - } #endif if ((labp = expand_index(&cint)) == NULL) { if (expand_clauses) { @@ -4233,7 +4194,7 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop USES_REGS) { if (cint.CodeStart) { if ((indx_out = Yap_assemble(ASSEMBLING_EINDEX, TermNil, ap, FALSE, &cint, cint.i_labelno+1)) == NULL) { if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); Yap_ReleaseCMem(&cint); CleanCls(&cint); return FAILCODE; @@ -4816,7 +4777,7 @@ kill_clause(yamop *ipc, yamop *bg, yamop *lt, path_stack_entry *sp0, PredEntry * /* weird case ????? */ if (!start->y_u.Illss.s){ /* ERROR */ - Yap_Error(INTERNAL_ERROR, TermNil, "Illss.s == 0 %p", ipc); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Illss.s == 0 %p", ipc); return sp; } if (start->y_u.Illss.s == 1) { @@ -5648,39 +5609,9 @@ Yap_AddClauseToIndex(PredEntry *ap, yamop *beg, int first) { LOCAL_ErrorMessage = NULL; #if DEBUG if (GLOBAL_Option['i' - 'a' + 1]) { - Term tmod = ap->ModuleOfPred; - if (!tmod) tmod = TermProlog; - Yap_DebugPutc(stderr,'+'); - Yap_DebugPutc(stderr,'\t'); - Yap_DebugPlWrite(tmod); - Yap_DebugPutc(stderr,':'); - if (ap->ModuleOfPred == IDB_MODULE) { - Term t = Deref(ARG1); - if (IsAtomTerm(t)) { - Yap_DebugPlWrite(t); - } else if (IsIntegerTerm(t)) { - Yap_DebugPlWrite(t); - } else { - Functor f = FunctorOfTerm(t); - Atom At = NameOfFunctor(f); - Yap_DebugPlWrite(MkAtomTerm(At)); - Yap_DebugPutc(stderr,'/'); - Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); - } - } else { - if (ap->ArityOfPE == 0) { - Atom At = (Atom)ap->FunctorOfPred; - Yap_DebugPlWrite(MkAtomTerm(At)); - } else { - Functor f = ap->FunctorOfPred; - Atom At = NameOfFunctor(f); - Yap_DebugPlWrite(MkAtomTerm(At)); - Yap_DebugPutc(stderr,'/'); - Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); - } - } - Yap_DebugPutc(stderr,'\n'); - } + Yap_DebugPutc(stderr,'+'); + Yap_DebugWriteIndicator( ap ); + } #endif stack = (path_stack_entry *)TR; cl.Code = cl.CurrentCode = beg; diff --git a/C/init.c b/C/init.c index ddda01935..795fb1118 100755 --- a/C/init.c +++ b/C/init.c @@ -496,7 +496,7 @@ Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, pred_flags_t flags) else atom = Yap_FullLookupAtom(Name); if (atom == NIL && !Yap_growheap(FALSE, 0L, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -504,7 +504,7 @@ Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, pred_flags_t flags) while (!f) { f = Yap_MkFunctor(atom,Arity); if (!f && !Yap_growheap(FALSE, 0L, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -515,7 +515,7 @@ Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, pred_flags_t flags) else pe = RepPredProp(PredPropByAtom(atom,CurrentModule)); if (!pe && !Yap_growheap(FALSE, sizeof(PredEntry), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -541,7 +541,7 @@ Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, pred_flags_t flags) cl = (StaticClause *)Yap_AllocCodeSpace(sz); if (!cl) { if (!Yap_growheap(FALSE, sz, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } else { @@ -645,7 +645,7 @@ Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, pred_flags_ while (atom == NIL) { atom = Yap_FullLookupAtom(Name); if (atom == NIL && !Yap_growheap(FALSE, 0L, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -653,7 +653,7 @@ Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, pred_flags_ while (!f) { f = Yap_MkFunctor(atom,Arity); if (!f && !Yap_growheap(FALSE, 0L, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -664,7 +664,7 @@ Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, pred_flags_ else pe = RepPredProp(PredPropByAtom(atom,CurrentModule)); if (!pe && !Yap_growheap(FALSE, sizeof(PredEntry), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -678,7 +678,7 @@ Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, pred_flags_ cl = (StaticClause *)Yap_AllocCodeSpace(sz); if (!cl) { if (!Yap_growheap(FALSE, sz, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } else { @@ -721,7 +721,7 @@ Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, pred_fl while (atom == NIL) { atom = Yap_FullLookupAtom(Name); if (atom == NIL && !Yap_growheap(FALSE, 0L, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -729,7 +729,7 @@ Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, pred_fl while (!f) { f = Yap_MkFunctor(atom,Arity); if (!f && !Yap_growheap(FALSE, 0L, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -740,7 +740,7 @@ Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, pred_fl else pe = RepPredProp(PredPropByAtom(atom,CurrentModule)); if (!pe && !Yap_growheap(FALSE, sizeof(PredEntry), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -763,7 +763,7 @@ Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, pred_fl cl = (StaticClause *)Yap_AllocCodeSpace((CELL)NEXTOP(NEXTOP(NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),e),Osbpp),p),p),l)); } if (!cl) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitAsmPred"); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"No Heap Space in InitAsmPred"); return; } Yap_ClauseSpace += (CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),Osbpp),p),l); @@ -814,7 +814,7 @@ CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont, CPredicate Cut) if (pe->cs.p_code.FirstClause != pe->cs.p_code.LastClause || pe->cs.p_code.TrueCodeOfPred != pe->cs.p_code.FirstClause || pe->CodeOfPred != pe->cs.p_code.FirstClause) { - Yap_Error(SYSTEM_ERROR,TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil, "initiating a C Pred with backtracking"); return; } @@ -875,7 +875,7 @@ Yap_InitCPredBack_(const char *Name, UInt Arity, while (atom == NIL) { atom = Yap_FullLookupAtom(Name); if (atom == NIL && !Yap_growheap(FALSE, 0L, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -883,7 +883,7 @@ Yap_InitCPredBack_(const char *Name, UInt Arity, while (!f) { f = Yap_MkFunctor(atom,Arity); if (!f && !Yap_growheap(FALSE, 0L, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -894,7 +894,7 @@ Yap_InitCPredBack_(const char *Name, UInt Arity, else pe = RepPredProp(PredPropByAtom(atom,CurrentModule)); if (!pe && !Yap_growheap(FALSE, sizeof(PredEntry), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"while initialising %s", Name); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"while initialising %s", Name); return; } } @@ -919,7 +919,7 @@ Yap_InitCPredBack_(const char *Name, UInt Arity, cl = (StaticClause *)Yap_AllocCodeSpace(sz); if (cl == NULL) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitCPredBack"); + Yap_Error(RESOURCE_ERROR_HEAP,TermNil,"No Heap Space in InitCPredBack"); return; } cl->ClFlags = StaticMask; @@ -995,7 +995,7 @@ InitPredHash(void) PredHash = (PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry **) * PredHashInitialSize); PredHashTableSize = PredHashInitialSize; if (PredHash == NULL) { - Yap_Error(FATAL_ERROR,MkIntTerm(0),"allocating initial predicate hash table"); + Yap_Error(SYSTEM_ERROR_FATAL,MkIntTerm(0),"allocating initial predicate hash table"); } for (i = 0; i < PredHashTableSize; ++i) { PredHash[i] = NULL; @@ -1089,7 +1089,7 @@ InitAtoms(void) AtomHashTableSize = MaxHash; HashChain = (AtomHashEntry *)Yap_AllocAtomSpace(sizeof(AtomHashEntry) * MaxHash); if (HashChain == NULL) { - Yap_Error(FATAL_ERROR,MkIntTerm(0),"allocating initial atom table"); + Yap_Error(SYSTEM_ERROR_FATAL,MkIntTerm(0),"allocating initial atom table"); } for (i = 0; i < MaxHash; ++i) { INIT_RWLOCK(HashChain[i].AERWLock); @@ -1121,7 +1121,7 @@ InitWideAtoms(void) WideAtomHashTableSize = MaxWideHash; WideHashChain = (AtomHashEntry *)Yap_AllocAtomSpace(sizeof(AtomHashEntry) * MaxWideHash); if (WideHashChain == NULL) { - Yap_Error(FATAL_ERROR,MkIntTerm(0),"allocating wide atom table"); + Yap_Error(SYSTEM_ERROR_FATAL,MkIntTerm(0),"allocating wide atom table"); } for (i = 0; i < MaxWideHash; ++i) { INIT_RWLOCK(WideHashChain[i].AERWLock); @@ -1152,7 +1152,7 @@ void Yap_init_yapor_workers(void) { int son; son = fork(); if (son == -1) - Yap_Error(FATAL_ERROR, TermNil, "fork error (Yap_init_yapor_workers)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "fork error (Yap_init_yapor_workers)"); if (son > 0) { /* I am the father, I must stay here and wait for my children to all die */ struct sigaction sigact; @@ -1170,7 +1170,7 @@ void Yap_init_yapor_workers(void) { int son; son = fork(); if (son == -1) - Yap_Error(FATAL_ERROR, TermNil, "fork error (Yap_init_yapor_workers)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "fork error (Yap_init_yapor_workers)"); if (son == 0) { /* new worker */ worker_id = proc; @@ -1260,7 +1260,7 @@ InitHandles(int wid) { handles = calloc(initial_slots , sizeof(CELL)); if(handles == NULL) { - Yap_Error(SYSTEM_ERROR, 0 /* TermNil */, "No space for handles at " __FILE__ " : %d", __LINE__); + Yap_Error(SYSTEM_ERROR_INTERNAL, 0 /* TermNil */, "No space for handles at " __FILE__ " : %d", __LINE__); } RESET_VARIABLE(handles); @@ -1394,7 +1394,7 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s #endif /* YAPOR || THREADS */ #ifdef YAPOR if (n_workers > MAX_WORKERS) - Yap_Error(INTERNAL_ERROR, TermNil, "excessive number of workers"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "excessive number of workers"); #ifdef YAPOR_COPY INFORMATION_MESSAGE("YapOr: copy model with %d worker%s", n_workers, n_workers == 1 ? "":"s"); #elif YAPOR_COW @@ -1437,7 +1437,7 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s if (Stack < MinStackSpace) Stack = MinStackSpace; if (!(LOCAL_GlobalBase = (ADDR)malloc((Trail+Stack)*1024))) { - Yap_Error(RESOURCE_ERROR_MEMORY, 0, "could not allocate stack space for main thread"); + Yap_Error(RESOURCE_ERROR_HEAP, 0, "could not allocate stack space for main thread"); Yap_exit(1); } #if THREADS diff --git a/C/inlines.c b/C/inlines.c index 06015f76f..369efa3cc 100644 --- a/C/inlines.c +++ b/C/inlines.c @@ -888,7 +888,7 @@ p_functor( USES_REGS1 ) /* functor(?,?,?) */ d0 = AbsAppl(HR); if (pt1+d1 > ENV - StackGap( PASS_REGS1 )) { if (!Yap_gcl((1+d1)*sizeof(CELL), 3, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } goto restart; @@ -993,7 +993,7 @@ p_cut_by( USES_REGS1 ) static Int p_erroneous_call( USES_REGS1 ) { - Yap_Error(SYSTEM_ERROR, TermNil, "bad call to internal built-in"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "bad call to internal built-in"); return(FALSE); } diff --git a/C/load_aout.c b/C/load_aout.c index 5778427b7..52d9cb1d2 100644 --- a/C/load_aout.c +++ b/C/load_aout.c @@ -96,7 +96,7 @@ Yap_FindExecutable(void) if (oktox(GLOBAL_Executable)) return GLOBAL_Executable; else - Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(GLOBAL_Executable)), + Yap_Error(SYSTEM_ERROR_INTERNAL,MkAtomTerm(Yap_LookupAtom(GLOBAL_Executable)), "cannot find file being executed"); } diff --git a/C/load_coff.c b/C/load_coff.c index e7f6da572..9bbfac7f8 100644 --- a/C/load_coff.c +++ b/C/load_coff.c @@ -92,7 +92,7 @@ Yap_FindExecutable(void) if (oktox(GLOBAL_Executable)) return GLOBAL_Executable; else - Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(GLOBAL_Executable)), + Yap_Error(SYSTEM_ERROR_INTERNAL,MkAtomTerm(Yap_LookupAtom(GLOBAL_Executable)), "cannot find file being executed"); return NULL; } diff --git a/C/load_dl.c b/C/load_dl.c index 37efee417..f533bef4c 100755 --- a/C/load_dl.c +++ b/C/load_dl.c @@ -55,7 +55,7 @@ Yap_CallFunctionByName(const char *thing_string) // you could do RTLD_NOW as well. shouldn't matter if (!handle) { CACHE_REGS - Yap_Error(SYSTEM_ERROR, ARG1, "Dynamic linking on main module : %s\n", dlerror()); + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "Dynamic linking on main module : %s\n", dlerror()); } prismf * addr = (prismf *)dlsym(handle, thing_string); if (addr) @@ -142,7 +142,7 @@ Yap_LoadForeignFile(char *file, int flags) out = (void *)dlopen(file,dlflag); if (!out) { CACHE_REGS - Yap_Error(SYSTEM_ERROR, ARG1, "dlopen error for %s: %s\n", file, dlerror()); + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "dlopen error for %s: %s\n", file, dlerror()); } return out; } @@ -152,7 +152,7 @@ Yap_CallForeignFile(void *handle, char *f) { YapInitProc proc = (YapInitProc) dlsym(handle, f); if (!proc) { - /* Yap_Error(SYSTEM_ERROR, ARG1, "dlsym error %s\n", dlerror());*/ + /* Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "dlsym error %s\n", dlerror());*/ return FALSE; } (*proc) (); @@ -164,7 +164,7 @@ Yap_CloseForeignFile(void *handle) { if ( dlclose(handle) < 0) { CACHE_REGS - Yap_Error(SYSTEM_ERROR, ARG1, "dlclose error %s\n", dlerror()); + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "dlclose error %s\n", dlerror()); return -1; } return 0; diff --git a/C/lu_absmi_insts.h b/C/lu_absmi_insts.h index 9ee9319c7..bc67bebdf 100644 --- a/C/lu_absmi_insts.h +++ b/C/lu_absmi_insts.h @@ -261,14 +261,14 @@ LOCAL_RetriesCounter--; if (LOCAL_RetriesCounter == 0) { saveregs(); - Yap_NilError(RETRY_COUNTER_UNDERFLOW,""); + Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -313,14 +313,14 @@ LOCAL_RetriesCounter--; if (LOCAL_RetriesCounter == 0) { saveregs(); - Yap_NilError(RETRY_COUNTER_UNDERFLOW,""); + Yap_NilError(RETRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -657,16 +657,16 @@ #if defined(YAPOR) || defined(THREADS) PP = NULL; #endif - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); FAIL(); } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_gc(3, ENV, CP)) { - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); FAIL(); } } @@ -769,5 +769,3 @@ #endif JMPNext(); ENDBOp(); - - diff --git a/C/prim_absmi_insts.h b/C/prim_absmi_insts.h index 755414238..665ff8746 100644 --- a/C/prim_absmi_insts.h +++ b/C/prim_absmi_insts.h @@ -2800,7 +2800,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxx),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -2917,7 +2917,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxc),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -3027,7 +3027,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gc(0, YREG, NEXTOP(NEXTOP(PREG,xxn),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -3134,7 +3134,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxx),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -3261,7 +3261,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxc),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -3389,7 +3389,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxn),Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -3765,7 +3765,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP(PREG,e),Osbmp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { diff --git a/C/qlyr.c b/C/qlyr.c index 6d4d5b951..c13aefb77 100755 --- a/C/qlyr.c +++ b/C/qlyr.c @@ -77,7 +77,7 @@ static void QLYR_ERROR(qlfr_err_t my_err) { // __android_log_print(ANDROID_LOG_INFO, "YAP ", "error %s in saved state %s",GLOBAL_RestoreFile, qlyr_error[my_err]); - Yap_Error(SAVED_STATE_ERROR,TermNil,"error %s in saved state %s",GLOBAL_RestoreFile, qlyr_error[my_err]); + Yap_Error(SYSTEM_ERROR_SAVED_STATE,TermNil,"error %s in saved state %s",GLOBAL_RestoreFile, qlyr_error[my_err]); Yap_exit(1); } diff --git a/C/save.c b/C/save.c index fc63538f1..6ac07c972 100755 --- a/C/save.c +++ b/C/save.c @@ -161,7 +161,7 @@ LightBug(s) #endif /* LIGHT */ static Int -do_system_error(yap_error_number etype, const char *msg) +do_SYSTEM_ERROR_INTERNAL(yap_error_number etype, const char *msg) { CACHE_REGS #if HAVE_SNPRINTF @@ -190,7 +190,7 @@ int myread(FILE *fd, char *buffer, Int len) { while (len > 0) { nread = fread(buffer, 1, (int)len, fd); if (nread < 1) { - return do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"bad read on saved state"); + return do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"bad read on saved state"); } buffer += nread; len -= nread; @@ -206,7 +206,7 @@ mywrite(FILE *fd, char *buff, Int len) { while (len > 0) { nwritten = fwrite(buff, 1, (size_t)len, fd); if (nwritten < 0) { - return do_system_error(SYSTEM_ERROR,"bad write on saved state"); + return do_SYSTEM_ERROR_INTERNAL(SYSTEM_ERROR_INTERNAL,"bad write on saved state"); } buff += nwritten; len -= nwritten; @@ -277,7 +277,7 @@ close_file(void) if (splfild == 0) return 0; if (fclose(splfild) < 0) - return do_system_error(SYSTEM_ERROR,"bad close on saved state"); + return do_SYSTEM_ERROR_INTERNAL(SYSTEM_ERROR_INTERNAL,"bad close on saved state"); splfild = 0; return 1; } @@ -314,7 +314,7 @@ get_header_cell(void) int n; while (count < sizeof(CELL)) { if ((n = fread(&l, 1, sizeof(CELL)-count, splfild)) < 0) { - do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to read saved state header"); + do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to read saved state header"); return 0L; } count += n; @@ -581,7 +581,7 @@ do_save(int mode USES_REGS) { Term t1 = Deref(ARG1); if (Yap_HoleSize) { - Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), + Yap_Error(SYSTEM_ERROR_INTERNAL,MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), "restore/1: address space has holes of size %ld, cannot save", (long int)Yap_HoleSize); return FALSE; } @@ -591,7 +591,7 @@ do_save(int mode USES_REGS) { } Yap_CloseStreams(TRUE); if ((splfild = open_file(LOCAL_FileNameBuf, O_WRONLY | O_CREAT)) < 0) { - Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), + Yap_Error(SYSTEM_ERROR_INTERNAL,MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), "restore/1, open(%s)", strerror(errno)); return(FALSE); } @@ -621,14 +621,14 @@ p_save2( USES_REGS1 ) Term t; #ifdef YAPOR if (GLOBAL_number_workers != 1) { - Yap_Error(SYSTEM_ERROR,TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil, "cannot perform save: more than a worker/thread running"); return(FALSE); } #endif /* YAPOR */ #ifdef THREADS if (GLOBAL_NOfThreads != 1) { - Yap_Error(SYSTEM_ERROR,TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil, "cannot perform save: more than a worker/thread running"); return(FALSE); } @@ -669,7 +669,7 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) pp[0] = '\0'; do { if ((n = fread(pp, 1, 1, splfild)) <= 0) { - do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan first line from saved state"); + do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan first line from saved state"); return FAIL_RESTORE; } } while (pp[0] != 1); @@ -679,7 +679,7 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) int count = 0, n, to_read = Unsigned(strlen(msg) + 1); while (count < to_read) { if ((n = fread(pp, 1, to_read-count, splfild)) <= 0) { - do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan version info from saved state"); + do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan version info from saved state"); return FAIL_RESTORE; } count += n; @@ -690,7 +690,7 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS) strncpy(LOCAL_ErrorMessage, "saved state ", MAX_ERROR_MSG_SIZE); strncat(LOCAL_ErrorMessage, LOCAL_FileNameBuf, MAX_ERROR_MSG_SIZE-1); strncat(LOCAL_ErrorMessage, " failed to match version ID", MAX_ERROR_MSG_SIZE-1); - LOCAL_Error_TYPE = CONSISTENCY_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_SAVED_STATE; return FAIL_RESTORE; } /* check info on header */ @@ -1151,7 +1151,7 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS) basep = (CELL *)TR; if (basep + (NOfE*2) > (CELL *)LOCAL_TrailTop) { if (!Yap_growtrail((ADDR)(basep + (NOfE*2))-LOCAL_TrailTop, TRUE)) { - Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, + Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, "not enough space to restore hash tables for indexing"); Yap_exit(1); } @@ -1295,7 +1295,7 @@ RestoreHashPreds( USES_REGS1 ) np = (PredEntry **) Yap_AllocAtomSpace(sizeof(PredEntry *)*size); if (!np) { if (!(np = (PredEntry **) malloc(sizeof(PredEntry *)*size))) { - Yap_Error(FATAL_ERROR,TermNil,"Could not allocate space for pred table"); + Yap_Error(SYSTEM_ERROR_FATAL,TermNil,"Could not allocate space for pred table"); return; } malloced = TRUE; @@ -1448,10 +1448,10 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac /* try to open from current directory */ /* could not open file */ if (LOCAL_ErrorMessage == NULL) { - do_system_error(PERMISSION_ERROR_OPEN_SOURCE_SINK,"incorrect saved state"); + do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_OPEN_SOURCE_SINK,"incorrect saved state"); } else { strncpy(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1); - do_system_error(PERMISSION_ERROR_OPEN_SOURCE_SINK,"could not open saved state"); + do_SYSTEM_ERROR_INTERNAL(PERMISSION_ERROR_OPEN_SOURCE_SINK,"could not open saved state"); } return FAIL_RESTORE; } @@ -1529,7 +1529,7 @@ RestoreHeap(OPCODE old_ops[] USES_REGS) if (!(Yap_ReInitConstExps() && Yap_ReInitUnaryExps() && Yap_ReInitBinaryExps())) { - Yap_Error(SYSTEM_ERROR, TermNil, "arithmetic operator not in saved state"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "arithmetic operator not in saved state"); } #ifdef DEBUG_RESTORE1 fprintf(errout, "phase 1 done\n"); @@ -1708,13 +1708,13 @@ p_restore( USES_REGS1 ) Term t1 = Deref(ARG1); #ifdef YAPOR if (GLOBAL_number_workers != 1) { - Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"cannot perform save: more than a worker/thread running"); return(FALSE); } #endif /* YAPOR */ #ifdef THREADS if (GLOBAL_NOfThreads != 1) { - Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"cannot perform save: more than a worker/thread running"); return(FALSE); } #endif /* THREADS */ diff --git a/C/scanner.c b/C/scanner.c index a4ad190e3..70ed84ae0 100755 --- a/C/scanner.c +++ b/C/scanner.c @@ -1102,7 +1102,7 @@ Term Yap_scan_num(StreamDesc *inp) { LOCAL_ScannerExtraBlocks = NULL; if (!(ptr = AllocScannerMemory(4096))) { LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; return TermNil; } ch = getchr(inp); @@ -1133,7 +1133,7 @@ Term Yap_scan_num(StreamDesc *inp) { #define CHECK_SPACE() \ if (ASP - HR < 1024) { \ LOCAL_ErrorMessage = "Stack Overflow"; \ - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; \ + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; \ LOCAL_Error_Size = 0L; \ if (p) \ p->Tok = Ord(kind = eot_tok); \ @@ -1256,7 +1256,7 @@ static wchar_t *ch_to_wide(char *base, char *charp) { wchar_t *nb = (wchar_t *)base; if ((nb + n) + 1024 > (wchar_t *)AuxSp) { - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; LOCAL_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)"; return NULL; @@ -1335,7 +1335,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream, t->TokNext = NULL; if (t == NULL) { LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; if (p) p->Tok = Ord(kind = eot_tok); /* serious error now */ @@ -1411,7 +1411,7 @@ scan_name: huge_var_error: /* huge atom or variable, we are in trouble */ LOCAL_ErrorMessage = "Code Space Overflow due to huge atom"; - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); if (p) p->Tok = Ord(kind = eot_tok); @@ -1437,7 +1437,7 @@ huge_var_error: ae = Yap_LookupAtom(TokImage); } if (ae == NIL) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; LOCAL_ErrorMessage = "Code Space Overflow"; if (p) t->Tok = Ord(kind = eot_tok); @@ -1468,7 +1468,7 @@ huge_var_error: cherr = 0; if (!(ptr = AllocScannerMemory(4096))) { LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; if (p) t->Tok = Ord(kind = eot_tok); /* serious error now */ @@ -1491,7 +1491,7 @@ huge_var_error: e = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); if (e == NULL) { LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; if (p) p->Tok = Ord(kind = eot_tok); /* serious error now */ @@ -1520,7 +1520,7 @@ huge_var_error: e2 = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); if (e2 == NULL) { LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; if (p) p->Tok = Ord(kind = eot_tok); /* serious error now */ @@ -1551,7 +1551,7 @@ huge_var_error: e2 = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); if (e2 == NULL) { LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; t->Tok = Ord(kind = eot_tok); /* serious error now */ return l; @@ -1583,7 +1583,7 @@ quoted_string: while (TRUE) { if (charp + 1024 > (char *)AuxSp) { - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; LOCAL_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)"; break; @@ -1620,7 +1620,7 @@ quoted_string: ++len; if (charp > (char *)AuxSp - 1024) { /* Not enough space to read in the string. */ - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; LOCAL_ErrorMessage = "not enough space to read in string or quoted atom"; /* serious error now */ @@ -1675,7 +1675,7 @@ quoted_string: t->TokInfo = Unsigned(Yap_LookupAtom(TokImage)); } if (!(t->TokInfo)) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; LOCAL_ErrorMessage = "Code Space Overflow"; if (p) t->Tok = Ord(kind = eot_tok); @@ -1767,7 +1767,7 @@ enter_symbol: ae = Yap_LookupAtom(TokImage); } if (ae == NIL) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; LOCAL_ErrorMessage = "Code Space Overflow"; if (p) t->Tok = Ord(kind = eot_tok); @@ -1776,7 +1776,7 @@ enter_symbol: } t->TokInfo = Unsigned(ae); if (t->TokInfo == (CELL)NIL) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; LOCAL_ErrorMessage = "Code Space Overflow"; if (p) t->Tok = Ord(kind = eot_tok); @@ -1932,7 +1932,7 @@ enter_symbol: } if (charp > (char *)AuxSp - 1024) { /* Not enough space to read in the string. */ - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; LOCAL_ErrorMessage = "not enough space to read in string or quoted atom"; /* serious error now */ @@ -1961,7 +1961,7 @@ enter_symbol: qq->end.linepos = inp_stream->linepos - 1; qq->end.charno = inp_stream->charcount - 1; if (!(t->TokInfo)) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; LOCAL_ErrorMessage = "Code Space Overflow"; if (p) t->Tok = Ord(kind = eot_tok); @@ -1997,7 +1997,7 @@ enter_symbol: TokEntry *e = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); if (e == NULL) { LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; p->Tok = Ord(kind = eot_tok); /* serious error now */ return l; diff --git a/C/signals.c b/C/signals.c index 7cc4819ff..6db8c24d9 100755 --- a/C/signals.c +++ b/C/signals.c @@ -363,7 +363,7 @@ p_first_signal( USES_REGS1 ) LOCAL_PrologMode |= AbortMode; return -1; } else { - Yap_Error(PURE_ABORT, TermNil, "abort from console"); + Yap_Error(ABORT_EVENT, TermNil, "abort from console"); } Yap_RestartYap( 1 ); return FALSE; diff --git a/C/sort.c b/C/sort.c index 859246872..bb6e60296 100644 --- a/C/sort.c +++ b/C/sort.c @@ -59,7 +59,7 @@ build_new_list(CELL *pt, Term t USES_REGS) pt += 2; if (pt > ASP - 4096) { if (!Yap_gcl((ASP-HR)*sizeof(CELL), 2, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return(FALSE); } t = Deref(ARG1); diff --git a/C/stack.c b/C/stack.c index a7c517de2..2e629016b 100644 --- a/C/stack.c +++ b/C/stack.c @@ -228,7 +228,7 @@ static yamop *cur_clause(PredEntry *pe, yamop *codeptr) break; cl = cl->ClNext; } while (TRUE); - Yap_Error(SYSTEM_ERROR,TermNil,"could not find clause for indexing code"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"could not find clause for indexing code"); return(NULL); } @@ -242,7 +242,7 @@ static yamop *cur_log_upd_clause(PredEntry *pe, yamop *codeptr) } cl = cl->ClNext; } while (cl != NULL); - Yap_Error(SYSTEM_ERROR,TermNil,"could not find clause for indexing code"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"could not find clause for indexing code"); return(NULL); } @@ -532,9 +532,9 @@ clause_loc(void *clcode, PredEntry *pp) { cl = ClauseCodeToLogUpdClause(clcode); if (cl->ClFlags & FactMask) { - return MkIntTerm(cl->lusl.ClLine); + return MkIntegerTerm(cl->lusl.ClLine); } else { - return MkIntTerm(cl->lusl.ClSource->ag.line_number); + return MkIntegerTerm(cl->lusl.ClSource->ag.line_number); } } else if (pp->PredFlags & DynamicPredFlag) { DynamicClause *cl; @@ -1041,7 +1041,7 @@ p_all_choicepoints( USES_REGS1 ) Term t; while ((t = all_cps(B PASS_REGS)) == 0L) { if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping choicepoints"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "while dumping choicepoints"); return FALSE; } } @@ -1054,7 +1054,7 @@ p_all_envs( USES_REGS1 ) Term t; while ((t = all_envs(ENV PASS_REGS)) == 0L) { if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping environments"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "while dumping environments"); return FALSE; } } @@ -1164,7 +1164,7 @@ current_stack( USES_REGS1 ) Term t; while ((t = all_calls( false PASS_REGS1 )) == 0L) { if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "while dumping stack"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "while dumping stack"); return FALSE; } } @@ -1625,6 +1625,428 @@ parent_pred( USES_REGS1 ) Yap_unify(ARG3, MkIntTerm(arity)); } +void Yap_dump_stack( void ); +void DumpActiveGoals( CACHE_TYPE1 ); +static int hidden(Atom); +static int legal_env(CELL * CACHE_TYPE); + +#define ONLOCAL(ptr) (CellPtr(ptr) > CellPtr(HR) && CellPtr(ptr) < CellPtr(LOCAL_LocalBase)) + +static int +hidden (Atom at) +{ + AtomEntry *chain; + + READ_LOCK(INVISIBLECHAIN.AERWLock); + chain = RepAtom(INVISIBLECHAIN.Entry); + while (!EndOfPAEntr (chain) && AbsAtom (chain) != at) + chain = RepAtom(chain->NextOfAE); + READ_UNLOCK(INVISIBLECHAIN.AERWLock); + if (EndOfPAEntr (chain)) + return (FALSE); + return (TRUE); +} + +static int +legal_env (CELL *ep USES_REGS) +{ + CELL cp, ps; + PredEntry *pe; + if (!ONLOCAL (ep) || Unsigned (ep) & 3) + return (FALSE); + cp = ep[E_CP]; + if (!ONHEAP (cp)) + return (FALSE); + ps = *((CELL *) (Addr (cp) - CellSize)); + pe = (PredEntry *) (ps - sizeof (OPREG) - sizeof (Prop)); + PELOCK(70,pe); + if (!ONHEAP (pe) || Unsigned (pe) & 3 || pe->KindOfPE & 0xff00) { + UNLOCK(pe->PELock); + return (FALSE); + } + UNLOCK(pe->PELock); + return (TRUE); +} + +static bool +handled_exception( USES_REGS1 ) +{ + yamop *pos = NEXTOP(PredDollarCatch->cs.p_code.TrueCodeOfPred,l); + bool found_handler = false; + choiceptr gc_b; + + gc_b = B; + while (gc_b) { + yamop *ap = gc_b->cp_ap; + if (ap == NOCODE) { + /* C-code: let they deal with that */ + return false; + } else if (ap == pos) { + if (found_handler) + return TRUE; /* we have two handlers */ + found_handler = true; + } + gc_b = gc_b->cp_b; + } + /* handled by Top c-code? */ + return !found_handler; +} + + + +void +Yap_dump_stack( void ) +{ + CACHE_REGS + choiceptr b_ptr = B; + CELL *env_ptr = ENV; + char tp[256]; + yamop *ipc = CP; + int max_count = 200; + + /* check if handled */ + if (handled_exception( PASS_REGS1 )) + return; +#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); + fprintf(stderr,"%% YAP mode: %ux\n",(unsigned int)LOCAL_PrologMode); + if (LOCAL_ErrorMessage) + fprintf(stderr,"%% LOCAL_ErrorMessage: %s\n",LOCAL_ErrorMessage); +#endif + if (HR > ASP || HR > LCL0) { + 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", HeapTop, LOCAL_GlobalBase); + } else { +#if !USE_SYSTEM_MALLOC + fprintf (stderr,"%ldKB of Code Space (%p--%p)\n",(long int)((CELL)HeapTop-(CELL)Yap_HeapBase)/1024,Yap_HeapBase,HeapTop); +#if USE_DL_MALLOC + if (Yap_NOfMemoryHoles) { + UInt i; + + for (i=0; i < Yap_NOfMemoryHoles; i++) + fprintf(stderr," Current hole: %p--%p\n", + Yap_MemoryHoles[i].start, + Yap_MemoryHoles[i].end); + } +#endif +#endif + Yap_detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256); + fprintf (stderr,"%%\n%% PC: %s\n",(char *)HR); + Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)HR, 256); + fprintf (stderr,"%% Continuation: %s\n",(char *)HR); + 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",(unsigned long int)(sizeof(CELL)*(LCL0-ASP))/1024,ASP,LCL0); + 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", (unsigned long int)LOCAL_GcCalls); +#if LOW_LEVEL_TRACER + { + extern long long vsc_count; + + if (vsc_count) { +#if _WIN32 + fprintf(stderr,"Trace Counter at %I64d\n",vsc_count); +#else + fprintf(stderr,"Trace Counter at %lld\n",vsc_count); +#endif + } + } +#endif + 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, tp, 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); + } else { + fprintf(stderr,"%% %s\n", tp); + } + if (!max_count--) { + fprintf(stderr,"%% .....\n"); + return; + } + ipc = (yamop *)(env_ptr[E_CP]); + env_ptr = (CELL *)(env_ptr[E_E]); + } + if (b_ptr) { + if (!max_count--) { + fprintf(stderr,"%% .....\n"); + return; + } + if (b_ptr->cp_ap && /* tabling */ + b_ptr->cp_ap->opc != Yap_opcode(_or_else) && + b_ptr->cp_ap->opc != Yap_opcode(_or_last) && + 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, tp, 256); + 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); + } + b_ptr = b_ptr->cp_b; + } + } + } +} + +void +DumpActiveGoals ( USES_REGS1 ) +{ + /* try to dump active goals */ + CELL *ep = YENV; /* and current environment */ + choiceptr b_ptr = B; + CELL cp; + PredEntry *pe; + int first = 1; + + if (legal_env (YENV PASS_REGS) && YENV < ENV) + ep = YENV; + else if (legal_env (ENV PASS_REGS)) + ep = ENV; + while (TRUE) + { + if (!ONLOCAL (ep) || (Unsigned (ep) & (sizeof(CELL)-1))) + break; + cp = ep[E_CP]; + if (!ONHEAP (cp) || (Unsigned (cp) & (sizeof(CELL)-1))) + break; + pe = EnvPreg((yamop *)cp); + if (!ONHEAP (pe) || Unsigned (pe) & (sizeof(CELL)-1)) + break; + PELOCK(71,pe); + if (pe->KindOfPE & 0xff00) { + UNLOCK(pe->PELock); + break; + } + if (pe->PredFlags & (CompiledPredFlag | DynamicPredFlag)) + { + Functor f; + + UNLOCK(pe->PELock); + f = pe->FunctorOfPred; + if (pe->KindOfPE && hidden (NameOfFunctor (f))) + goto next; + if (first++ == 1) + fprintf(stderr,"Active ancestors:\n"); + Yap_DebugWriteIndicator(pe); + Yap_DebugPutc (stderr,'\n'); + } else { + UNLOCK(pe->PELock); + } + next: + ep = (CELL *) ep[E_E]; + } + first = 1; + fprintf(stderr,"Active Choice-Points:\n"); + while (TRUE) + { + PredEntry *pe; + op_numbers opnum; + if (!ONLOCAL (b_ptr) || b_ptr->cp_b == NULL) + break; + fprintf(stderr,"%p ", b_ptr); + pe = Yap_PredForChoicePt(b_ptr, &opnum); + if (opnum == _Nstop) { + fprintf(stderr, " ********** C-Code Interface Boundary ***********\n"); + } else { + Functor f; + Term mod = PROLOG_MODULE; + + f = pe->FunctorOfPred; + if (pe->ModuleOfPred) + mod = pe->ModuleOfPred; + else mod = TermProlog; + if (mod != TermProlog && + mod != MkAtomTerm(AtomUser) ) { + Yap_DebugPlWrite (mod); + Yap_DebugPutc (stderr,':'); + } + if (mod == IDB_MODULE) { + if (pe->PredFlags & NumberDBPredFlag) { + Int id = pe->src.IndxId; + Yap_DebugPlWrite(MkIntegerTerm(id)); + } else if (pe->PredFlags & AtomDBPredFlag) { + Atom At = (Atom)pe->FunctorOfPred; + Yap_DebugPlWrite(MkAtomTerm(At)); + } else { + Functor f = pe->FunctorOfPred; + Atom At = NameOfFunctor(f); + arity_t arity = ArityOfFunctor(f); + int i; + + Yap_DebugPlWrite(MkAtomTerm(At)); + Yap_DebugPutc (stderr,'('); + for (i= 0; i < arity; i++) { + if (i > 0) Yap_DebugPutc (stderr,','); + Yap_DebugPutc (stderr,'_'); + } + Yap_DebugPutc (stderr,')'); + } + Yap_DebugPutc (stderr,'('); + Yap_DebugPlWrite(b_ptr->cp_a2); + Yap_DebugPutc (stderr,')'); + } else if (pe->ArityOfPE == 0) { + Yap_DebugPlWrite (MkAtomTerm ((Atom)f)); + } else { + Int i = 0, arity = pe->ArityOfPE; + if (opnum == _or_last|| + opnum == _or_else) { + Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor (f))); + Yap_DebugPutc (stderr,'('); + for (i= 0; i < arity; i++) { + if (i > 0) Yap_DebugPutc (stderr,','); + Yap_DebugPutc(stderr, '_'); + } + Yap_DebugErrorPuts (") :- ... ( _ ; _ "); + } else { + Term *args = &(b_ptr->cp_a1); + Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor (f))); + Yap_DebugPutc (stderr,'('); + for (i= 0; i < arity; i++) { + if (i > 0) Yap_DebugPutc (stderr,','); + Yap_DebugPlWrite(args[i]); + } + } + Yap_DebugPutc (stderr,')'); + } + Yap_DebugPutc (stderr,'\n'); + } + b_ptr = b_ptr->cp_b; + } +} + + +void +Yap_detect_bug_location(yamop *yap_pc, int where_from, char *tp, int psize) +{ + Atom pred_name; + UInt pred_arity; + Term pred_module; + Int cl; + + tp[0] = '\0'; + if ((cl = Yap_PredForCode(yap_pc, where_from, &pred_name, &pred_arity, &pred_module)) + == 0) { + /* system predicate */ +#if HAVE_SNPRINTF + snprintf(tp, psize, "%s", + "meta-call"); +#else + sprintf(tp, "%s", + "meta-call"); +#endif + } else if (pred_module == 0) { + /* don't give info on system predicates */ +#if HAVE_SNPRINTF + snprintf(tp, psize, "prolog:%s/%lu", + RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); +#else + sprintf(tp, "in prolog:%s/%lu", + RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); +#endif + } else if (cl < 0) { +#if HAVE_SNPRINTF + snprintf(tp, psize, "%s:%s/%lu", + RepAtom(AtomOfTerm(pred_module))->StrOfAE, + RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); +#else + sprintf(tp, "%s:%s/%lu", + RepAtom(AtomOfTerm(pred_module))->StrOfAE, + RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); +#endif + } else { +#if HAVE_SNPRINTF + snprintf(tp, psize, "%s:%s/%lu at clause %lu ", + RepAtom(AtomOfTerm(pred_module))->StrOfAE, + RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity, (unsigned long int)cl); +#else + sprintf(tp, "%s:%s/%lu at clause %lu", + RepAtom(AtomOfTerm(pred_module))->StrOfAE, + RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity, (unsigned long int)cl); +#endif + } +} + +Term +Yap_bug_location(yamop *codeptr, choiceptr b_ptr, CELL *env) +{ + CACHE_REGS + Term p[5]; + while ( true ) { + PredEntry *pe= EnvPreg(codeptr); + if (pe && + pe->ModuleOfPred != PROLOG_MODULE + && !(pe->PredFlags & HiddenPredFlag)) { + if (pe->ModuleOfPred == PROLOG_MODULE) + p[0] = TermProlog; + else + p[0] = pe->ModuleOfPred; + if (pe->ArityOfPE) + p[1] = MkAtomTerm(NameOfFunctor(pe->FunctorOfPred)); + else + p[1] = MkAtomTerm((Atom)pe->FunctorOfPred); + p[2] = MkIntegerTerm( pe->ArityOfPE ); + if (pe->src.OwnerFile) { + p[3] = MkAtomTerm(pe->src.OwnerFile); + if (pe->PredFlags & MegaClausePredFlag) { + MegaClause *mcl; + mcl = + ClauseCodeToMegaClause(pe->cs.p_code.FirstClause); + p[4] = MkIntegerTerm( mcl->ClLine ); + } else { + CODEADDR clcode; + if ( find_code_in_clause( pe, codeptr, &clcode, NULL) > 0 ) { + if (pe->PredFlags & LogUpdatePredFlag) { + LogUpdClause *cl = ClauseCodeToLogUpdClause(clcode); + + if (cl->ClFlags & FactMask) { + p[4] = MkIntegerTerm(cl->lusl.ClLine); + } else { + p[4] = MkIntegerTerm(cl->lusl.ClSource->ag.line_number); + } + } else if (pe->PredFlags & DynamicPredFlag) { + DynamicClause *cl; + cl = ClauseCodeToDynamicClause(clcode); + + p[4] = MkIntTerm(0); + } else { + StaticClause *cl; + cl = ClauseCodeToStaticClause(clcode); + + if (cl->ClFlags & FactMask) { + p[4] = MkIntTerm(cl->usc.ClLine); + } else if (cl->ClFlags & SrcMask) { + p[4] = MkIntTerm(cl->usc.ClSource->ag.line_number); + } else + p[4] = MkIntTerm(0); + } + } + } + } else if (pe->OpcodeOfPred == UNDEF_OPCODE) { + RESET_VARIABLE(p+3); + RESET_VARIABLE(p+4); + } else { + // by default, user_input + p[3] = MkAtomTerm(AtomUserIn); + p[4] = MkIntTerm(0); + } + return Yap_MkApplTerm( Yap_MkFunctor(Yap_LookupAtom("p"), 5), 5, p); + } else { + if (b_ptr && (CELL*)b_ptr < env) { + env = b_ptr->cp_env; + b_ptr = b_ptr->cp_b; + } else { + env = ENV_Parent(env); + } + } + } +} + + + void Yap_InitStInfo(void) diff --git a/C/stackinfo.c b/C/stackinfo.c index f27792bd7..10a7c7ce6 100644 --- a/C/stackinfo.c +++ b/C/stackinfo.c @@ -187,7 +187,7 @@ static yamop *cur_clause(PredEntry *pe, yamop *codeptr) break; cl = cl->ClNext; } while (TRUE); - Yap_Error(SYSTEM_ERROR,TermNil,"could not find clause for indexing code"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"could not find clause for indexing code"); return(NULL); } @@ -201,7 +201,7 @@ static yamop *cur_log_upd_clause(PredEntry *pe, yamop *codeptr) } cl = cl->ClNext; } while (cl != NULL); - Yap_Error(SYSTEM_ERROR,TermNil,"could not find clause for indexing code"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"could not find clause for indexing code"); return(NULL); } diff --git a/C/stdpreds.c b/C/stdpreds.c index 3f60fafd2..f235130ab 100755 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -223,7 +223,7 @@ * replace heap_base by Yap_heap_base, according to Yap's convention for globals. * * Revision 1.74 2004/11/19 22:08:43 vsc -* replace SYSTEM_ERROR by out OUT_OF_WHATEVER_ERROR whenever appropriate. +* replace SYSTEM_ERROR_INTERNAL by out OUT_OF_WHATEVER_ERROR whenever appropriate. * * Revision 1.73 2004/11/19 17:14:14 vsc * a few fixes for 64 bit compiling. @@ -713,7 +713,7 @@ static Int p_univ(USES_REGS1) { /* A =.. L */ /* restore space */ HR = Ar; if (!Yap_gcl((ASP - HR) * sizeof(CELL), 2, ENV, gc_P(P, CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } twork = TailOfTerm(Deref(ARG2)); @@ -781,7 +781,7 @@ static Int p_univ(USES_REGS1) { /* A =.. L */ twork = Yap_ArrayToList(CellPtr(TR), argno - 1); while (IsIntTerm(twork)) { if (!Yap_gc(2, ENV, gc_P(P, CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return (FALSE); } twork = Yap_ArrayToList(CellPtr(TR), argno - 1); @@ -791,7 +791,7 @@ static Int p_univ(USES_REGS1) { /* A =.. L */ { while (HR + arity * 2 > ASP - 1024) { if (!Yap_gcl((arity * 2) * sizeof(CELL), 2, ENV, gc_P(P, CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return (FALSE); } tin = Deref(ARG1); @@ -809,7 +809,7 @@ static Int p_univ(USES_REGS1) { /* A =.. L */ static Int p_abort(USES_REGS1) { /* abort */ /* make sure we won't go creeping around */ - Yap_Error(PURE_ABORT, TermNil, ""); + Yap_Error(ABORT_EVENT, TermNil, ""); return (FALSE); } diff --git a/C/text.c b/C/text.c index 39f53c042..83a10493b 100644 --- a/C/text.c +++ b/C/text.c @@ -486,7 +486,7 @@ write_strings( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng Term t = init_tstring( PASS_REGS1 ); unsigned char *cp = s, *buf; - LOCAL_TERM_ERROR( 2*(lim-s) ); + LOCAL_TERM_ERROR( t, 2*(lim-s) ); buf = buf_from_tstring(HR); while (*cp && cp < lim) { utf8proc_int32_t chr; @@ -510,7 +510,7 @@ write_strings( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng unsigned char *buf; utf8proc_int32_t chr; - LOCAL_TERM_ERROR( 2*(lim-s) ); + LOCAL_TERM_ERROR( t, 2*(lim-s) ); buf = buf_from_tstring(HR); while (cp < lim) { cp = get_char(cp, &chr); @@ -531,7 +531,7 @@ write_strings( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng wchar_t *wp = s; unsigned char *buf; - LOCAL_TERM_ERROR( 2*(lim-s) ); + LOCAL_TERM_ERROR( t, 2*(lim-s) ); buf = buf_from_tstring(HR); while (wp < lim) { utf8proc_int32_t chr; @@ -548,7 +548,7 @@ write_strings( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng } break; default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); } return out->val.t; @@ -574,7 +574,7 @@ write_atoms( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U unsigned char *cp = s; wchar_t w[2]; w[1] = '\0'; - LOCAL_TERM_ERROR( 2*(lim-s) ); + LOCAL_TERM_ERROR( t, 2*(lim-s) ); while (cp < lim && *cp) { utf8proc_int32_t chr; CELL *cl; @@ -596,7 +596,7 @@ write_atoms( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U char w[2]; w[1] = '\0'; - LOCAL_TERM_ERROR( 2*(lim-s) ); + LOCAL_TERM_ERROR( t, 2*(lim-s) ); while (cp < lim) { utf8proc_int32_t chr; cp = get_char(cp, &chr); @@ -616,7 +616,7 @@ write_atoms( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U wchar_t w[2]; w[1] = '\0'; - LOCAL_TERM_ERROR( 2*(lim-s) ); + LOCAL_TERM_ERROR( t, 2*(lim-s) ); while (*cp && cp < lim) { utf8proc_int32_t chr; cp = get_wchar(cp, &chr); @@ -631,7 +631,7 @@ write_atoms( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U break; } default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); } if (out->type & YAP_STRING_DIFF) { if (sz == 0) t = out->dif; @@ -660,7 +660,7 @@ write_codes( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U case ENC_ISO_UTF8: { unsigned char *s = s0, *lim = s + strnlen(s0, max); unsigned char *cp = s; - LOCAL_TERM_ERROR( 2*(lim-s) ); + LOCAL_TERM_ERROR( t, 2*(lim-s) ); while (*cp && cp < lim) { utf8proc_int32_t chr; cp += get_utf8(cp, &chr); @@ -676,7 +676,7 @@ write_codes( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U { unsigned char *s = s0, *lim = s + strnlen(s0, max); unsigned char *cp = s; - LOCAL_TERM_ERROR( 2*(lim-s) ); + LOCAL_TERM_ERROR( t, 2*(lim-s) ); while (cp < lim) { utf8proc_int32_t chr; cp = get_char(cp, &chr); @@ -692,7 +692,7 @@ write_codes( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U { wchar_t *s = s0, *lim = s + wcsnlen(s, max); wchar_t *cp = s; - LOCAL_TERM_ERROR( 2*(lim-s) ); + LOCAL_TERM_ERROR( t, 2*(lim-s) ); while (cp < lim) { utf8proc_int32_t chr; cp = get_wchar(cp, &chr); @@ -705,7 +705,7 @@ write_codes( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng U break; } default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); } while (sz < min) { HR[0] = MkIntTerm(MkIntTerm(0)); @@ -768,7 +768,7 @@ write_atom( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng US return at; } default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc)); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc)); } return NULL; } @@ -852,7 +852,7 @@ write_wbuffer( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng break; default: sz_end = -1; - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); } } sz_end *= sizeof( wchar_t ); @@ -944,7 +944,7 @@ write_buffer( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng break; default: sz_end = -1; - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); } }else if (out->enc == ENC_ISO_LATIN1) { switch (enc) { @@ -999,7 +999,7 @@ write_buffer( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng break; default: sz_end = -1; - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); } } else { // no other encodings are supported. @@ -1041,7 +1041,7 @@ write_length( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng return wcsnlen(s, max); } default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); } return (size_t)-1; } @@ -1151,7 +1151,7 @@ compute_end( void *s0, encoding_t enc ) return s + (1+wcslen(s)); } default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); } return NULL; } @@ -1167,7 +1167,7 @@ advance_Text( void *s, int l, encoding_t enc ) case ENC_WCHAR: return ((wchar_t *)s)+l; default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc), __FUNCTION__); } return s; } @@ -1198,7 +1198,7 @@ cmp_Text( void *s1, void *s2, int l, encoding_t enc1, encoding_t enc2 ) } return 0; default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc2), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc2), __FUNCTION__); } } case ENC_ISO_UTF8: @@ -1227,7 +1227,7 @@ cmp_Text( void *s1, void *s2, int l, encoding_t enc1, encoding_t enc2 ) } return 0; default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc2), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc2), __FUNCTION__); } } case ENC_WCHAR: @@ -1251,11 +1251,11 @@ cmp_Text( void *s1, void *s2, int l, encoding_t enc1, encoding_t enc2 ) case ENC_WCHAR: return wcsncmp(s1, s2, l); default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc2), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc2), __FUNCTION__); } } default: - Yap_Error(SYSTEM_ERROR, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc1), __FUNCTION__); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Unsupported Encoding ~s in %s", enc_name(enc1), __FUNCTION__); } return 0; } @@ -1302,7 +1302,7 @@ concat( int n, seq_tv_t *out, void *sv[], encoding_t encv[], size_t lengv[] USES /* wide atom */ wchar_t *buf = (wchar_t *)HR; Atom at; - LOCAL_ERROR( sz+3 ); + LOCAL_ERROR( MkAtomTerm(Yap_LookupWideAtom(buf)), sz+3 ); for (i = 0; i < n ; i ++) { if (encv[i] == ENC_WCHAR) { wchar_t *ptr = sv[i]; @@ -1326,7 +1326,7 @@ concat( int n, seq_tv_t *out, void *sv[], encoding_t encv[], size_t lengv[] USES char *buf = (char *)HR; Atom at; - LOCAL_TERM_ERROR( sz/sizeof(CELL)+3 ); + LOCAL_ERROR( MkAtomTerm(Yap_LookupAtom(buf)), sz/sizeof(CELL)+3 ); for (i = 0; i < n ; i ++) { char *ptr = sv[i]; utf8proc_int32_t chr; @@ -1373,7 +1373,7 @@ slice( size_t min, size_t max, void *buf, seq_tv_t *out, encoding_t enc USES_REG wchar_t *nbuf = (wchar_t *)HR; wchar_t *ptr = (wchar_t *)buf + min; if (max>min) { - LOCAL_ERROR( (max-min)*sizeof(wchar_t) ); + LOCAL_ERROR( MkAtomTerm(Yap_LookupWideAtom(buf)), (max-min)*sizeof(wchar_t) ); memcpy( nbuf, ptr, (max - min)*sizeof(wchar_t)); } nbuf[max-min] = '\0'; @@ -1384,7 +1384,7 @@ slice( size_t min, size_t max, void *buf, seq_tv_t *out, encoding_t enc USES_REG if (max>min) { char *ptr = (char *)buf + min; - LOCAL_ERROR( max-min ); + LOCAL_ERROR( MkAtomTerm(Yap_LookupAtom(buf)), max-min ); memcpy( nbuf, ptr, (max - min)); } nbuf[max-min] = '\0'; @@ -1395,7 +1395,7 @@ slice( size_t min, size_t max, void *buf, seq_tv_t *out, encoding_t enc USES_REG unsigned char *ptr = skip_utf8 ( ( unsigned char *)buf, min ); utf8proc_int32_t chr; - LOCAL_ERROR( max-min ); + LOCAL_ERROR( MkAtomTerm(Yap_LookupAtom(buf)), max-min ); while ( min++ < max ) { ptr += get_utf8(ptr, & chr); *nbuf++ = chr; } nbuf[0] = '\0'; at = Yap_LookupMaybeWideAtom( (wchar_t*)HR ); diff --git a/C/threads.c b/C/threads.c index 67b3126cf..fc270680d 100644 --- a/C/threads.c +++ b/C/threads.c @@ -422,17 +422,17 @@ thread_run(void *widp) do { t = tgs[0] = Yap_PopTermFromDB(LOCAL_ThreadHandle.tgoal); if (t == 0) { - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, LOCAL_ErrorMessage); thread_die(worker_id, FALSE); return NULL; } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growstack(LOCAL_ThreadHandle.tgoal->NOfCells*CellSize)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); thread_die(worker_id, FALSE); return NULL; } @@ -551,9 +551,9 @@ p_thread_sleep( USES_REGS1 ) req.tv_nsec = ntime; if (nanosleep(&req, &oreq)) { #if HAVE_STRERROR - Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "%s in thread_sleep/1", strerror(errno)); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "%s in thread_sleep/1", strerror(errno)); #else - Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "error %d in thread_sleep/1", errno); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "error %d in thread_sleep/1", errno); #endif return FALSE; } @@ -563,15 +563,15 @@ p_thread_sleep( USES_REGS1 ) UInt rtime; if ((rtime = sleep(time)) < 0) { #if HAVE_STRERROR - Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "%s in thread_sleep/1", strerror(errno)); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "%s in thread_sleep/1", strerror(errno)); #else - Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "error %d in thread_sleep/1", errno); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "error %d in thread_sleep/1", errno); #endif } return Yap_unify(ARG3,MkIntegerTerm(rtime)) && Yap_unify(ARG4,MkIntTerm(0L)); #else - Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "no support for thread_sleep/1 in this YAP configuration"); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "no support for thread_sleep/1 in this YAP configuration"); #endif } @@ -1461,17 +1461,17 @@ p_thread_atexit( USES_REGS1 ) do { t = Yap_PopTermFromDB(LOCAL_ThreadHandle.texit); if (t == 0) { - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { - Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, TermNil, LOCAL_ErrorMessage); thread_die(worker_id, FALSE); return FALSE; } } else { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growstack(LOCAL_ThreadHandle.tgoal->NOfCells*CellSize)) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); thread_die(worker_id, FALSE); return FALSE; } diff --git a/C/traced_absmi_insts.h b/C/traced_absmi_insts.h index b543ece20..d916bc35b 100644 --- a/C/traced_absmi_insts.h +++ b/C/traced_absmi_insts.h @@ -777,14 +777,14 @@ CACHE_Y(YREG); SET_ASP(YREG, E_CB*sizeof(CELL)); saveregs(); while ((t = Yap_FetchTermFromDB(cl->lusl.ClSource)) == 0L) { - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { UNLOCKPE(3,PP); #if defined(YAPOR) || defined(THREADS) PP = NULL; #endif - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); FAIL(); } } else { @@ -794,7 +794,7 @@ CACHE_Y(YREG); #if defined(YAPOR) || defined(THREADS) PP = NULL; #endif - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); FAIL(); } } @@ -918,7 +918,7 @@ CACHE_Y(YREG); PREG = NEXTOP(PREG,Osbpa); saveregs(); if (!Yap_gcl(sz, arity, YENV, PREG)) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); FAIL(); } else { @@ -12793,7 +12793,7 @@ S_SREG = RepAppl(d0); ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_VV_SECONDIFOK_FIRSTIFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -12974,7 +12974,7 @@ S_SREG = RepAppl(d0); ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_CV_D1GREATER_IFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -13139,7 +13139,7 @@ S_SREG = RepAppl(d0); ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_VC_IFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -13307,7 +13307,7 @@ S_SREG = RepAppl(d0); ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_Y_VV_D1GREATER_IFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -13498,7 +13498,7 @@ S_SREG = RepAppl(d0); ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_Y_CV_D1GREATER_IFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -13684,7 +13684,7 @@ S_SREG = RepAppl(d0); ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_Y_VC_IFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -14182,7 +14182,7 @@ S_SREG = RepAppl(d0); /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP(PREG,e),Osbmp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { diff --git a/C/udi.c b/C/udi.c index 826de8b4d..0b726ac9a 100644 --- a/C/udi.c +++ b/C/udi.c @@ -76,7 +76,7 @@ p_new_udi( USES_REGS1 ) blk = (UdiInfo) Yap_AllocCodeSpace(sizeof(struct udi_info)); memset((void *) blk,0, sizeof(struct udi_info)); if (!blk) { - Yap_Error(OUT_OF_HEAP_ERROR, spec, "new user index/1"); + Yap_Error(RESOURCE_ERROR_HEAP, spec, "new user index/1"); return FALSE; } diff --git a/C/unify.c b/C/unify.c index 4eaf5ef4d..a11627bbb 100644 --- a/C/unify.c +++ b/C/unify.c @@ -607,7 +607,7 @@ InitReverseLookupOpcode(void) while (OP_RTABLE == NULL) { if ((OP_RTABLE = (op_entry *)Yap_AllocCodeSpace(sz)) == NULL) { if (!Yap_growheap(FALSE, sz, NULL)) { - Yap_Error(INTERNAL_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Couldn't obtain space for the reverse translation opcode table"); } } diff --git a/C/utilpreds.c b/C/utilpreds.c index 400fff2f6..4c807d76c 100644 --- a/C/utilpreds.c +++ b/C/utilpreds.c @@ -371,7 +371,7 @@ handle_cp_overflow(int res, tr_fr_ptr TR0, UInt arity, Term t) switch(res) { case -1: if (!Yap_gcl((ASP-HR)*sizeof(CELL), arity+1, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return 0L; } return Deref(XREGS[arity+1]); @@ -384,14 +384,14 @@ handle_cp_overflow(int res, tr_fr_ptr TR0, UInt arity, Term t) if (size > 4*1024*1024) size = 4*1024*1024; if (!Yap_ExpandPreAllocCodeSpace(size, NULL, TRUE)) { - Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, TermNil, LOCAL_ErrorMessage); return 0L; } } return Deref(XREGS[arity+1]); case -4: if (!Yap_growtrail((TR-TR0)*sizeof(tr_fr_ptr *), FALSE)) { - Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, LOCAL_ErrorMessage); return 0L; } return Deref(XREGS[arity+1]); @@ -1270,7 +1270,7 @@ Yap_ImportTerm(char * buf) { // if not enough stack available while (HR + sz > ASP - 4096) { if (!Yap_gcl( (sz+4096)*sizeof(CELL), PP->ArityOfPE, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return 0L; } } @@ -1462,7 +1462,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *); clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); @@ -1478,7 +1478,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; @@ -1495,7 +1495,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; LOCAL_Error_Size = (ASP-HR)*sizeof(CELL); return 0L; @@ -1509,12 +1509,12 @@ expand_vts( int args USES_REGS ) LOCAL_Error_Size = 0; LOCAL_Error_TYPE = YAP_NO_ERROR; - if (yap_errno == OUT_OF_TRAIL_ERROR) { + if (yap_errno == RESOURCE_ERROR_TRAIL) { /* Trail overflow */ if (!Yap_growtrail(expand, FALSE)) { return FALSE; } - } else if (yap_errno == OUT_OF_AUXSPACE_ERROR) { + } else if (yap_errno == RESOURCE_ERROR_AUXILIARY_STACK) { /* Aux space overflow */ if (expand > 4*1024*1024) expand = 4*1024*1024; @@ -1523,7 +1523,7 @@ expand_vts( int args USES_REGS ) } } else { if (!Yap_gcl(expand, 3, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in term_variables"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "in term_variables"); return FALSE; } } @@ -1811,7 +1811,7 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *); clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); @@ -1827,7 +1827,7 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; @@ -1844,7 +1844,7 @@ static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; LOCAL_Error_Size = (ASP-HR)*sizeof(CELL); return 0L; @@ -2043,7 +2043,7 @@ static Term vars_within_complex_term(register CELL *pt0, register CELL *pt0_end, *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *); clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); @@ -2059,7 +2059,7 @@ static Term vars_within_complex_term(register CELL *pt0, register CELL *pt0_end, *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; @@ -2076,7 +2076,7 @@ static Term vars_within_complex_term(register CELL *pt0, register CELL *pt0_end, clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; LOCAL_Error_Size = (ASP-HR)*sizeof(CELL); return 0L; @@ -2248,7 +2248,7 @@ static Term new_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *); clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); @@ -2264,7 +2264,7 @@ static Term new_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; @@ -2281,7 +2281,7 @@ static Term new_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; LOCAL_Error_Size = (ASP-HR)*sizeof(CELL); return 0L; @@ -2437,7 +2437,7 @@ static Term free_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *); clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); @@ -2453,7 +2453,7 @@ static Term free_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; @@ -2470,7 +2470,7 @@ static Term free_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; LOCAL_Error_Size = (ASP-HR)*sizeof(CELL); return 0L; @@ -2582,7 +2582,7 @@ static Term bind_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *); clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); @@ -2598,7 +2598,7 @@ static Term bind_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; @@ -2825,7 +2825,7 @@ p_non_singletons_in_term( USES_REGS1 ) /* non_singletons in term t */ return Yap_unify(ARG3,out); } else { if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { - Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, "overflow in singletons"); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, "overflow in singletons"); return FALSE; } } @@ -2971,7 +2971,7 @@ int Yap_IsGroundTerm(Term t) if (out < 0) { *HR++ = t; if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { - Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, "overflow in ground"); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, "overflow in ground"); return FALSE; } t = *--HR; @@ -3584,13 +3584,13 @@ Yap_TermHash(Term t, Int size, Int depth, int variant) CELL *ar = hash_complex_term(&t1-1, &t1, depth, HR, FALSE PASS_REGS); if (ar == (CELL *)-1) { if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { - Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, "overflow in term_hash"); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, "overflow in term_hash"); return FALSE; } t1 = Deref(ARG1); } else if(ar == (CELL *)-2) { if (!Yap_gcl((ASP-HR)*sizeof(CELL), 0, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in term_hash"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "in term_hash"); return FALSE; } t1 = Deref(ARG1); @@ -3641,13 +3641,13 @@ p_term_hash( USES_REGS1 ) CELL *ar = hash_complex_term(&t1-1, &t1, depth, HR, FALSE PASS_REGS); if (ar == (CELL *)-1) { if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { - Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, "overflow in term_hash"); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, "overflow in term_hash"); return FALSE; } t1 = Deref(ARG1); } else if(ar == (CELL *)-2) { if (!Yap_gcl((ASP-HR)*sizeof(CELL), 4, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in term_hash"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "in term_hash"); return FALSE; } t1 = Deref(ARG1); @@ -3699,13 +3699,13 @@ p_instantiated_term_hash( USES_REGS1 ) CELL *ar = hash_complex_term(&t1-1, &t1, depth, HR, TRUE PASS_REGS); if (ar == (CELL *)-1) { if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { - Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, "overflow in term_hash"); + Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, "overflow in term_hash"); return FALSE; } t1 = Deref(ARG1); } else if(ar == (CELL *)-2) { if (!Yap_gcl((ASP-HR)*sizeof(CELL), 4, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in term_hash"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "in term_hash"); return FALSE; } t1 = Deref(ARG1); @@ -3952,7 +3952,7 @@ is_variant(Term t1, Term t2, int parity USES_REGS) error: if (out == -1) { if (!Yap_gcl((ASP-HR)*sizeof(CELL), parity, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in variant"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "in variant"); return FALSE; } return is_variant(t1, t2, parity PASS_REGS); @@ -4501,13 +4501,13 @@ p_term_subsumer( USES_REGS1 ) /* term_subsumer terms t1 and t2 */ HR = oldH; if (out == -1) { if (!Yap_gcl((ASP-HR)*sizeof(CELL), 0, ENV, gc_P(P,CP))) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in term_subsumer"); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "in term_subsumer"); return FALSE; } } else { /* Trail overflow */ if (!Yap_growtrail(0, FALSE)) { - Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "in term_subsumer"); + Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, "in term_subsumer"); return FALSE; } } @@ -4728,7 +4728,7 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL; LOCAL_Error_Size = (TR-TR0)*sizeof(tr_fr_ptr *); clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); @@ -4744,7 +4744,7 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end *pt0 = (CELL)to_visit[2]; } #endif - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; @@ -4761,7 +4761,7 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); HR = InitialH; - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; LOCAL_Error_Size = (ASP-HR)*sizeof(CELL); return -1; @@ -4908,7 +4908,7 @@ unnumber_complex_term(CELL *pt0, CELL *pt0_end, CELL *ptf, CELL *HLow, int share Int id = IntegerOfTerm(ap2[1]); ground = FALSE; if (id < -1) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, "unnumber vars cannot cope with VAR(-%d)", id); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "unnumber vars cannot cope with VAR(-%d)", id); return 0L; } if (id <= max) { diff --git a/C/write.c b/C/write.c index 8f50d032b..644052090 100644 --- a/C/write.c +++ b/C/write.c @@ -224,7 +224,7 @@ static char *ensure_space(size_t sz) { if (!s) { s = (char *)HR; if (s + sz >= (char *)ASP) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, + Yap_Error(RESOURCE_ERROR_STACK, TermNil, "not enough space to write bignum: it requires %d bytes", sz); s = NULL; } diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user index 29ed36a4e..b7244c7e2 100644 --- a/CMakeLists.txt.user +++ b/CMakeLists.txt.user @@ -1,10 +1,10 @@ - + EnvironmentId - {378dfb04-c1f5-4fa0-86e6-78c9ff000795} + {a0de746c-c885-4e01-9456-e8e37fff153e} ProjectExplorer.Project.ActiveTarget @@ -32,18 +32,18 @@ UTF-8 false 4 - true + false 80 true true 1 true false - 1 + 0 true - 1 + 0 8 - false + true 1 true true @@ -65,13 +65,13 @@ Desktop Desktop - {272d81a6-7879-4ae0-b3cf-b19e1dbf86c9} + {372e928c-645c-4a2e-be60-0afb86ba4bb0} 0 0 0 false - /Users/vsc/Yap/bins/t + /Users/vsc/Yap/bins/Qt @@ -162,13 +162,10 @@ 14 yap-bin - -l /Users/vsc/share/logtalk/integration/logtalk_yap -z "start_low_level_trace,{'~/Yap/logtalk3/tests/prolog/predicates/open_4/tester'}" - false - /Users/vsc/share/logtalk + + 2 - - LOGTALKHOME=/Users/vsc/share/logtalk - + yap-bin CMakeProjectManager.CMakeRunConfiguration.yap-bin @@ -216,7 +213,6 @@ Problogbdd - false 2 @@ -267,7 +263,6 @@ Problogbdd-Lfi - false 2 @@ -318,7 +313,6 @@ HorusCli - false 2 @@ -332,58 +326,7 @@ false true - - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - qtyap - - false - - 2 - - qtyap - - CMakeProjectManager.CMakeRunConfiguration.qtyap - 3768 - false - true - false - false - true - - 5 + 4 diff --git a/CXX/yapi.cpp b/CXX/yapi.cpp index 04e0a831e..0af155c44 100644 --- a/CXX/yapi.cpp +++ b/CXX/yapi.cpp @@ -617,7 +617,7 @@ YAPEngine::YAPEngine( char *savedState, if (cb) setYAPCallback(cb); curren = this; if (YAP_Init( &init_args ) == YAP_BOOT_ERROR) - throw(YAPError(INTERNAL_ERROR)); + throw(YAPError(SYSTEM_ERROR_INTERNAL)); } diff --git a/H/YapFlags.h b/H/YapFlags.h index 142997443..fb0f0384b 100644 --- a/H/YapFlags.h +++ b/H/YapFlags.h @@ -23,134 +23,129 @@ #ifndef YAP_FLAGS_H #define YAP_FLAGS_H 1 -//INLINE_ONLY inline EXTERN bool nat( Term inp ); +// INLINE_ONLY inline EXTERN bool nat( Term inp ); -static inline bool nat( Term inp ) { +static inline bool nat(Term inp) { if (IsVarTerm(inp)) { - Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in 0..."); + Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s", "bound"); return false; } if (IsIntTerm(inp)) { Int i = IntOfTerm(inp); - if (i >= 0) return true; - Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, inp, "set_prolog_flag in 0..."); + if (i >= 0) + return true; + Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, inp, "set_prolog_flag: value must be %s", ">= 0"); return false; } - Yap_Error(TYPE_ERROR_INTEGER, inp, "set_prolog_flag in 0..."); + Yap_Error(TYPE_ERROR_INTEGER, inp, "set_prolog_flag: value must be %s", "integer"); return false; } -static inline bool at2n( Term inp ) { - Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag."); +static inline bool at2n(Term inp) { + Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s", "flag is read-only"); return false; } -static inline bool isfloat( Term inp ) { +static inline bool isfloat(Term inp) { if (IsVarTerm(inp)) { - Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in 0.0."); + Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s", "integer"); + return false; } if (IsFloatTerm(inp)) { return true; } - Yap_Error(TYPE_ERROR_FLOAT, inp, "set_prolog_flag in 0..."); + Yap_Error(TYPE_ERROR_FLOAT, inp, "set_prolog_flag: value must be %s", "floating-point"); return false; } -INLINE_ONLY inline EXTERN bool ro( Term inp ); +INLINE_ONLY inline EXTERN bool ro(Term inp); -INLINE_ONLY inline EXTERN bool ro( Term inp ) { +INLINE_ONLY inline EXTERN bool ro(Term inp) { if (IsVarTerm(inp)) { - Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in 0..."); + Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s", "bound"); return false; } - Yap_Error( PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag."); + Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s", "flag is read-only"); return false; } - -INLINE_ONLY inline EXTERN bool aro( Term inp ) { +INLINE_ONLY inline EXTERN bool aro(Term inp) { if (IsVarTerm(inp)) { - Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in 0..."); + Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s", "value must be bound"); + return false; } - Yap_Error( PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag."); + Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s", "flag is read-only"); + return false; } -//INLINE_ONLY inline EXTERN bool boolean( Term inp ); +// INLINE_ONLY inline EXTERN bool boolean( Term inp ); -static inline bool boolean( Term inp ) { - if (inp == TermTrue || - inp == TermFalse|| - inp == TermOn|| - inp == TermOff ) +static inline bool boolean(Term inp) { + if (inp == TermTrue || inp == TermFalse || inp == TermOn || inp == TermOff) return true; if (IsVarTerm(inp)) { - Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in {true,false,on,off"); + Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s", "value must be bound"); +; return false; } if (IsAtomTerm(inp)) { - Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag in {true,false,on,off}"); + Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, + "set_prolog_flag in {true,false,on,off}"); return false; } Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {true,false,on,off"); return false; } -static bool synerr( Term inp ) { - if (inp == TermDec10 || - inp == TermFail|| - inp == TermError|| - inp == TermQuiet ) +static bool synerr(Term inp) { + if (inp == TermDec10 || inp == TermFail || inp == TermError || + inp == TermQuiet) return true; if (IsAtomTerm(inp)) { - Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag in {dec10,error,fail,quiet}"); + Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, + "set_prolog_flag in {dec10,error,fail,quiet}"); return false; } - Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {dec10,error,fail,quiet}"); + Yap_Error(TYPE_ERROR_ATOM, inp, + "set_prolog_flag in {dec10,error,fail,quiet}"); return false; } +static inline bool filler(Term inp) { return true; } -static inline bool filler( Term inp ) -{ - return true; -} - -static bool bqs( Term inp ) { - if (inp == TermCodes || - inp == TermString|| - inp == TermSymbolChar ) +static bool bqs(Term inp) { + if (inp == TermCodes || inp == TermString || inp == TermSymbolChar) return true; if (IsAtomTerm(inp)) { - Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag in {codes,string}"); + Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, + "set_prolog_flag in {codes,string}"); return false; } Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {codes,string}"); return false; } -//INLINE_ONLY inline EXTERN bool isatom( Term inp ); +// INLINE_ONLY inline EXTERN bool isatom( Term inp ); -static inline bool isatom( Term inp ) { +static inline bool isatom(Term inp) { if (IsVarTerm(inp)) { - Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag"); + Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s", "value must be bound"); return false; } - if (IsAtomTerm(inp) ) + if (IsAtomTerm(inp)) return true; - Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flagm"); + Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag"); return false; } // INLINE_ONLY inline EXTERN bool ok( Term inp ); -static inline bool ok( Term inp ) { - return true; -} +static inline bool ok(Term inp) { return true; } // a pair, obtained from x(y) -> 1,2,y) typedef struct x_el { @@ -172,28 +167,27 @@ typedef struct struct_param2 { } param2_t; typedef struct { - char *name; + char *name; bool writable; flag_func def; const char *init; flag_func helper; } flag_info; - -typedef struct { +typedef struct { char *name; flag_func def; const char *init; } arg_info; typedef union flagTerm { - Term at; - struct DB_TERM *DBT; + Term at; + struct DB_TERM *DBT; } flag_term; -void Yap_InitFlags( bool ); +void Yap_InitFlags(bool); -#define YAP_FLAG( x, NAME, WRITABLE, DEF, INIT, HELPER ) x +#define YAP_FLAG(x, NAME, WRITABLE, DEF, INIT, HELPER) x typedef enum { #include "YapGFlagInfo.h" @@ -204,28 +198,22 @@ typedef enum { } local_flag_t; #undef YAP_FLAG +bool setYapFlag(Term tflag, Term t2); +Term getYapFlag(Term tflag); -bool setYapFlag( Term tflag, Term t2 ); -Term getYapFlag( Term tflag ); +static inline bool check_refs_to_ltable(void) { return true; } -static inline bool check_refs_to_ltable( void ) { - return true; -} - -static inline void setAtomicGlobalPrologFlag(int id, Term v) -{ +static inline void setAtomicGlobalPrologFlag(int id, Term v) { GLOBAL_Flags[id].at = v; } -static inline void setAtomicLocalPrologFlag(int id, Term v) -{ - CACHE_REGS - check_refs_to_ltable(); - LOCAL_Flags[id].at = v; +static inline void setAtomicLocalPrologFlag(int id, Term v) { + CACHE_REGS + check_refs_to_ltable(); + LOCAL_Flags[id].at = v; } -static inline void setBooleanLocalPrologFlag(int id, bool v) -{ +static inline void setBooleanLocalPrologFlag(int id, bool v) { CACHE_REGS check_refs_to_ltable(); if (v) { @@ -235,43 +223,37 @@ static inline void setBooleanLocalPrologFlag(int id, bool v) } } -static inline void setBooleanGlobalPrologFlag(int id, bool v) -{ +static inline void setBooleanGlobalPrologFlag(int id, bool v) { if (v) { - GLOBAL_Flags[id].at = TermTrue; - } else { - GLOBAL_Flags[id].at = TermFalse; + GLOBAL_Flags[id].at = TermTrue; + } else { + GLOBAL_Flags[id].at = TermFalse; } } -static inline bool trueGlobalPrologFlag(int id) -{ - return GLOBAL_Flags[id].at == TermTrue; - +static inline bool trueGlobalPrologFlag(int id) { + return GLOBAL_Flags[id].at == TermTrue; } -static inline bool falseGlobalPrologFlag(int id) -{ - return GLOBAL_Flags[id].at == TermFalse; +static inline bool falseGlobalPrologFlag(int id) { + return GLOBAL_Flags[id].at == TermFalse; } -static inline bool trueLocalPrologFlag(int id) -{ - CACHE_REGS - return LOCAL_Flags[id].at == TermTrue; +static inline bool trueLocalPrologFlag(int id) { + CACHE_REGS + return LOCAL_Flags[id].at == TermTrue; } -static inline bool falsePrologFlag(int id) -{ - CACHE_REGS - return LOCAL_Flags[id].at == TermFalse; +static inline bool falsePrologFlag(int id) { + CACHE_REGS + return LOCAL_Flags[id].at == TermFalse; } -static inline bool isoLanguageFlag(void){ +static inline bool isoLanguageFlag(void) { return GLOBAL_Flags[ISO_FLAG].at == TermTrue; } -static inline bool strictISOFlag(void){ +static inline bool strictISOFlag(void) { return GLOBAL_Flags[STRICT_ISO_FLAG].at == TermTrue; } @@ -280,53 +262,49 @@ static inline bool silentMode(void) { } static inline void setVerbosity(Term val) { - GLOBAL_Flags[VERBOSE_FLAG].at = val; + GLOBAL_Flags[VERBOSE_FLAG].at = val; } static inline bool setSyntaxErrorsFlag(Term val) { - if (!synerr( val )) + if (!synerr(val)) return false; - CACHE_REGS - LOCAL_Flags[SYNTAX_ERRORS_FLAG].at = val; - return true; + CACHE_REGS + LOCAL_Flags[SYNTAX_ERRORS_FLAG].at = val; + return true; } static inline Term getSyntaxErrorsFlag(void) { - CACHE_REGS + CACHE_REGS return LOCAL_Flags[SYNTAX_ERRORS_FLAG].at; } static inline bool setBackQuotesFlag(Term val) { - if (!bqs( val )) + if (!bqs(val)) return false; if (val == TermSymbolChar) val = TermString; GLOBAL_Flags[BACKQUOTED_STRING_FLAG].at = val; - return true; + return true; } static inline Term getBackQuotesFlag(void) { - return GLOBAL_Flags[BACKQUOTED_STRING_FLAG].at; + return GLOBAL_Flags[BACKQUOTED_STRING_FLAG].at; } -static inline int indexingMode(void) { - return GLOBAL_Flags[INDEX_FLAG].at; -} +static inline int indexingMode(void) { return GLOBAL_Flags[INDEX_FLAG].at; } -static inline const char *floatFormat(void) { +static inline const char *floatFormat(void) { return RepAtom(AtomOfTerm(GLOBAL_Flags[FLOAT_FORMAT_FLAG].at))->rep.uStrOfAE; } -static inline size_t indexingDepth(void) { +static inline size_t indexingDepth(void) { return IntOfTerm(GLOBAL_Flags[INDEX_SUB_TERM_SEARCH_DEPTH_FLAG].at); } bool rmdot(Term inp); +xarg *Yap_ArgListToVector(Term listl, const param_t *def, int n); -xarg * Yap_ArgListToVector (Term listl, const param_t *def, int n); +xarg *Yap_ArgList2ToVector(Term listl, const param2_t *def, int n); -xarg * Yap_ArgList2ToVector (Term listl, const param2_t *def, int n); - - -#endif // YAP_FLAGS_H +#endif // YAP_FLAGS_H diff --git a/H/YapHandles.h b/H/YapHandles.h index 019ab3512..86de7d6ef 100755 --- a/H/YapHandles.h +++ b/H/YapHandles.h @@ -17,14 +17,17 @@ #define YAP_HANDLES_H 1 #include "Regs.h" - /** @groupdef term_t_slots -Also known as term handles, slots are offsets to entries in the local stack. YAP never compresses the local stack, so slots are respected by the garbage collector, -hence providing a way to access terms without being exposed to stack shifts or garbage-collection. +Also known as term handles, slots are offsets to entries in the local stack. YAP +never compresses the local stack, so slots are respected by the garbage +collector, +hence providing a way to access terms without being exposed to stack shifts or +garbage-collection. - Space is released when the function terminates. Thus, slots will be automatically released at the end + Space is released when the function terminates. Thus, slots will be +automatically released at the end of a function. Hence, slots should always be used as local variables. Slots are organized as follows: @@ -36,15 +39,18 @@ Entry Entry ---- Number of entries (tagged as handle_t), in the example TAG(INT,4) -Slots are not known to the yaam. Instead, A new set of slots is created when the emulator calls user C-code. +Slots are not known to the yaam. Instead, A new set of slots is created when the +emulator calls user C-code. (see YAP_Execute* functions). They are also created: - by SWI's PL_foreign_frame() function, - - by the YAP_RunGoal() routines and friends, when they exit successfully. Notice that all handles created by c-goals within + - by the YAP_RunGoal() routines and friends, when they exit successfully. +Notice that all handles created by c-goals within a `Goal` execution should not be used afterwards. - This section lists the main internal functions for slot management. These functions are then exported through corresponding FLI C-functions + This section lists the main internal functions for slot management. These +functions are then exported through corresponding FLI C-functions *************************************************************************************************/ @@ -52,170 +58,147 @@ Slots are not known to the yaam. Instead, A new set of slots is created when the /// @brief reboot the slot system. /// Used when wwe start from scratch (Reset). -#define Yap_RebootSlots( wid ) Yap_RebootSlots__( wid PASS_REGS ) +#define Yap_RebootSlots(wid) Yap_RebootSlots__(wid PASS_REGS) -static inline void -Yap_RebootSlots__( int wid USES_REGS ) { +static inline void Yap_RebootSlots__(int wid USES_REGS) { // // fprintf(stderr, " StartSlots = %ld", LOCAL_CurSlot); REMOTE_CurSlot(wid) = 1; } - /// @brief declares a new set of slots. /// Used to tell how many slots we had when we entered a segment of code. -#define Yap_StartSlots() Yap_StartSlots__( PASS_REGS1 ) +#define Yap_StartSlots() Yap_StartSlots__(PASS_REGS1) -static inline yhandle_t -Yap_StartSlots__( USES_REGS1 ) { +static inline yhandle_t Yap_StartSlots__(USES_REGS1) { // // fprintf(stderr, " StartSlots = %ld", LOCAL_CurSlot); - // fprintf(stderr,"SS %s:%d\n", __FUNCTION__, __LINE__);; -if (LOCAL_CurSlot < 0) { - Yap_Error( SYSTEM_ERROR, 0L, " StartSlots = %ld", LOCAL_CurSlot); + // fprintf(stderr,"SS %s:%d\n", __FUNCTION__, __LINE__);; + if (LOCAL_CurSlot < 0) { + Yap_Error(SYSTEM_ERROR_INTERNAL, 0L, " StartSlots = %ld", LOCAL_CurSlot); } return LOCAL_CurSlot; } - /// @brief reset slots to a well-known position in the stack -#define Yap_CloseSlots( slot ) Yap_CloseSlots__( slot PASS_REGS ) +#define Yap_CloseSlots(slot) Yap_CloseSlots__(slot PASS_REGS) -static inline void -Yap_CloseSlots__( yhandle_t slot USES_REGS ) { - // fprintf(stderr,"CS %s:%d\n", __FUNCTION__, __LINE__);; +static inline void Yap_CloseSlots__(yhandle_t slot USES_REGS) { + // fprintf(stderr,"CS %s:%d\n", __FUNCTION__, __LINE__);; LOCAL_CurSlot = slot; } -/// @brief report the current position of the slots, assuming that they occupy the top of the stack. -static inline yhandle_t -Yap_CurrentSlot( USES_REGS1 ) { - return LOCAL_CurSlot; -} +/// @brief report the current position of the slots, assuming that they occupy +/// the top of the stack. +static inline yhandle_t Yap_CurrentSlot(USES_REGS1) { return LOCAL_CurSlot; } #define Yap_GetFromSlot(slot) Yap_GetFromSlot__(slot PASS_REGS) /// @brief read from a slot. -static inline Term -Yap_GetFromSlot__(yhandle_t slot USES_REGS) -{ - // fprintf(stderr,"GS %s:%d\n", __FUNCTION__, __LINE__);; - return(Deref(LOCAL_SlotBase[slot])); +static inline Term Yap_GetFromSlot__(yhandle_t slot USES_REGS) { + // fprintf(stderr,"GS %s:%d\n", __FUNCTION__, __LINE__);; + return (Deref(LOCAL_SlotBase[slot])); } /// @brief read from a slot. but does not try to dereference the slot. -static inline Term -Yap_GetDerefedFromSlot(yhandle_t slot USES_REGS) -{ - // fprintf(stderr,"GDS %s:%d\n", __FUNCTION__, __LINE__); +static inline Term Yap_GetDerefedFromSlot(yhandle_t slot USES_REGS) { + // fprintf(stderr,"GDS %s:%d\n", __FUNCTION__, __LINE__); return LOCAL_SlotBase[slot]; } /// @brief read the object in a slot. but do not try to dereference the slot. -static inline Term -Yap_GetPtrFromSlot(yhandle_t slot USES_REGS) -{ - // fprintf(stderr,"GPS %s:%d\n", __FUNCTION__, __LINE__); +static inline Term Yap_GetPtrFromSlot(yhandle_t slot USES_REGS) { + // fprintf(stderr,"GPS %s:%d\n", __FUNCTION__, __LINE__); return LOCAL_SlotBase[slot]; } -#define Yap_AddressFromSlot( slot ) Yap_AddressFromSlot__(slot PASS_REGS) - +#define Yap_AddressFromSlot(slot) Yap_AddressFromSlot__(slot PASS_REGS) /// @brief get the memory address of a slot -static inline Term * -Yap_AddressFromSlot__(yhandle_t slot USES_REGS) -{ - return LOCAL_SlotBase+slot; +static inline Term *Yap_AddressFromSlot__(yhandle_t slot USES_REGS) { + return LOCAL_SlotBase + slot; } /// @brief store term in a slot -static inline void -Yap_PutInSlot(yhandle_t slot, Term t USES_REGS) -{ - // fprintf(stderr,"PS %s:%d\n", __FUNCTION__, __LINE__); +static inline void Yap_PutInSlot(yhandle_t slot, Term t USES_REGS) { + // fprintf(stderr,"PS %s:%d\n", __FUNCTION__, __LINE__); LOCAL_SlotBase[slot] = t; } #ifndef max -#define max(X,Y) ( X > Y ? X : Y ) +#define max(X, Y) (X > Y ? X : Y) #endif -static inline void -ensure_slots(int N USES_REGS) -{ - if (LOCAL_CurSlot+N >= LOCAL_NSlots) { - size_t inc = max(16*1024, LOCAL_NSlots/2); // measured in cells - inc = max(inc, N+16); // measured in cells - LOCAL_SlotBase = (CELL *)realloc( LOCAL_SlotBase, (inc + LOCAL_NSlots )*sizeof(CELL)); +static inline void ensure_slots(int N USES_REGS) { + if (LOCAL_CurSlot + N >= LOCAL_NSlots) { + size_t inc = max(16 * 1024, LOCAL_NSlots / 2); // measured in cells + inc = max(inc, N + 16); // measured in cells + LOCAL_SlotBase = + (CELL *)realloc(LOCAL_SlotBase, (inc + LOCAL_NSlots) * sizeof(CELL)); LOCAL_NSlots += inc; if (!LOCAL_SlotBase) { - unsigned long int kneeds = ((inc + LOCAL_NSlots )*sizeof(CELL))/1024; - Yap_Error(SYSTEM_ERROR, 0 /* TermNil */, "Out of memory for the term handles (term_t) aka slots, l needed", kneeds); + unsigned long int kneeds = ((inc + LOCAL_NSlots) * sizeof(CELL)) / 1024; + Yap_Error( + SYSTEM_ERROR_INTERNAL, 0 /* TermNil */, + "Out of memory for the term handles (term_t) aka slots, l needed", + kneeds); } } } -#define Yap_InitSlot( t ) Yap_InitSlot__( t PASS_REGS ) +#define Yap_InitSlot(t) Yap_InitSlot__(t PASS_REGS) /// @brief create a new slot with term t -static inline yhandle_t -Yap_InitSlot__(Term t USES_REGS) -{ +static inline yhandle_t Yap_InitSlot__(Term t USES_REGS) { yhandle_t old_slots = LOCAL_CurSlot; // fprintf(stderr,"IS %s:%d\n", __FUNCTION__, __LINE__); - ensure_slots( 1 PASS_REGS); + ensure_slots(1 PASS_REGS); LOCAL_SlotBase[old_slots] = t; LOCAL_CurSlot++; return old_slots; } -#define Yap_NewSlots( n ) Yap_NewSlots__( n PASS_REGS ) +#define Yap_NewSlots(n) Yap_NewSlots__(n PASS_REGS) /// @brief allocate n empty new slots -static inline yhandle_t -Yap_NewSlots__(int n USES_REGS) -{ +static inline yhandle_t Yap_NewSlots__(int n USES_REGS) { yhandle_t old_slots = LOCAL_CurSlot; int i; // fprintf(stderr,"NS %s:%d\n", __FUNCTION__, __LINE__); ensure_slots(n PASS_REGS); - for (i = 0; i< n; i++) { - LOCAL_SlotBase[old_slots+i] = MkVarTerm(); + for (i = 0; i < n; i++) { + LOCAL_SlotBase[old_slots + i] = MkVarTerm(); } LOCAL_CurSlot += n; return old_slots; } -#define Yap_InitSlots(n, ts) Yap_InitSlots__(n, ts PASS_REGS) +#define Yap_InitSlots(n, ts) Yap_InitSlots__(n, ts PASS_REGS) /// @brief create n new slots with terms ts[] - static inline yhandle_t -Yap_InitSlots__(int n, Term *ts USES_REGS) -{ +static inline yhandle_t Yap_InitSlots__(int n, Term *ts USES_REGS) { yhandle_t old_slots = LOCAL_CurSlot; int i; // fprintf(stderr,"1S %s:%d\n", __FUNCTION__, __LINE__); - ensure_slots( n PASS_REGS); - for (i=0; i< n; i++) - LOCAL_SlotBase[old_slots+i] = ts[i]; + ensure_slots(n PASS_REGS); + for (i = 0; i < n; i++) + LOCAL_SlotBase[old_slots + i] = ts[i]; LOCAL_CurSlot += n; return old_slots; } -/// @brief Succeeds if it is to recover the space allocated for $n$ contiguos slots starting at topSlot. -static inline bool -Yap_RecoverSlots(int n, yhandle_t topSlot USES_REGS) -{ +/// @brief Succeeds if it is to recover the space allocated for $n$ contiguos +/// slots starting at topSlot. +static inline bool Yap_RecoverSlots(int n, yhandle_t topSlot USES_REGS) { if (topSlot + n < LOCAL_CurSlot) return false; - // fprintf(stderr,"RS %s:%d\n", __FUNCTION__, __LINE__); - #ifdef DEBUG +// fprintf(stderr,"RS %s:%d\n", __FUNCTION__, __LINE__); +#ifdef DEBUG if (topSlot + n > LOCAL_CurSlot) { - Yap_Error(SYSTEM_ERROR, 0 /* TermNil */, "Inconsistent slot state in Yap_RecoverSlots."); + Yap_Error(SYSTEM_ERROR_INTERNAL, 0 , "Inconsistent slot state in Yap_RecoverSlots.", 0); return false; } - #endif +#endif return true; } diff --git a/H/Yapproto.h b/H/Yapproto.h index 2ba7307d7..9033c7174 100755 --- a/H/Yapproto.h +++ b/H/Yapproto.h @@ -170,8 +170,6 @@ void Yap_RestartYap(int); void Yap_exit(int); bool Yap_Warning( const char *s, ... ); bool Yap_PrintWarning( Term t ); -yamop *Yap_Error(yap_error_number,Term,const char *msg, ...); -yamop *Yap_NilError(yap_error_number,const char *msg, ...); int Yap_HandleError( const char *msg, ... ); int Yap_SWIHandleError( const char *, ... ); @@ -288,6 +286,7 @@ void Yap_InitIOPreds(void); extern void Yap_DebugPlWrite (Term t); extern void Yap_DebugErrorPutc (int n); extern void Yap_DebugErrorPuts (const char *s); +extern void Yap_DebugWriteIndicator( struct pred_entry *ap ); #endif void Yap_PlWriteToStream(Term, int, int); /* depth_lim.c */ @@ -364,7 +363,10 @@ void Yap_InitSockets (void); void Yap_InitSortPreds(void); /* stack.c */ -void Yap_InitStInfo(void); +void Yap_InitStInfo(void); +void Yap_dump_stack( void ); +void Yap_detect_bug_location(yamop *yap_pc, int where_from, char *tp, int psize); + #if !defined(YAPOR) && !defined(THREADS) bool Yap_search_for_static_predicate_in_use(struct pred_entry *, bool); #endif diff --git a/H/clause.h b/H/clause.h index 8035fd46b..c4667758b 100644 --- a/H/clause.h +++ b/H/clause.h @@ -473,9 +473,7 @@ Term Yap_LUInstance(LogUpdClause *, UInt); int Yap_new_udi_clause(PredEntry *, yamop *, Term); yamop *Yap_udi_search(PredEntry *); -#ifdef DEBUG -void Yap_bug_location(yamop *); -#endif +Term Yap_bug_location(yamop *codeptr, choiceptr b_ptr, CELL *env); #if LOW_PROF void Yap_InformOfRemoval(void *); diff --git a/H/iatoms.h b/H/iatoms.h index 847005825..b21080624 100644 --- a/H/iatoms.h +++ b/H/iatoms.h @@ -243,7 +243,7 @@ AtomOn = Yap_LookupAtom("on"); AtomOnline = Yap_LookupAtom("online"); AtomOpen = Yap_LookupAtom("open"); - AtomOperatingSystemError = Yap_LookupAtom("operating_system_error"); + AtomOperatingSystemError = Yap_LookupAtom("operating_SYSTEM_ERROR_INTERNAL"); AtomOperatingSystemSupport = Yap_LookupAtom("operating_system_support"); AtomOperator = Yap_LookupAtom("operator"); AtomOperatorPriority = Yap_LookupAtom("operator_priority"); @@ -356,7 +356,7 @@ AtomSyntaxErrors = Yap_LookupAtom("syntax_errors"); AtomSyntaxErrorHandler = Yap_LookupAtom("syntax_error_handler"); AtomSystem = Yap_LookupAtom("system"); - AtomSystemError = Yap_LookupAtom("system_error"); + AtomSystemError = Yap_LookupAtom("SYSTEM_ERROR_INTERNAL"); AtomSystemLibraryDir = Yap_LookupAtom("system_library_directory"); AtomTerm = Yap_LookupAtom("term"); AtomTerms = Yap_LookupAtom("terms"); diff --git a/H/iswiatoms.h b/H/iswiatoms.h index b2f945fe8..4dcddb8ae 100644 --- a/H/iswiatoms.h +++ b/H/iswiatoms.h @@ -617,7 +617,7 @@ YAP_AtomToInt(Yap_LookupAtom("syntax_error")); YAP_AtomToInt(Yap_LookupAtom("syntax_errors")); YAP_AtomToInt(Yap_LookupAtom("system")); - YAP_AtomToInt(Yap_LookupAtom("system_error")); + YAP_AtomToInt(Yap_LookupAtom("SYSTEM_ERROR_INTERNAL")); YAP_AtomToInt(Yap_LookupAtom("system_init_file")); YAP_AtomToInt(Yap_LookupAtom("system_thread_id")); YAP_AtomToInt(Yap_LookupAtom("system_time")); diff --git a/H/rheap.h b/H/rheap.h index 285c780d6..f3a879788 100644 --- a/H/rheap.h +++ b/H/rheap.h @@ -409,7 +409,7 @@ AdjustSwitchTable__(op_numbers op, yamop *table, COUNT i USES_REGS) } break; default: - Yap_Error(INTERNAL_ERROR,0L,"Opcode Not Implemented in AdjustSwitchTable"); + Yap_Error(SYSTEM_ERROR_INTERNAL,0L,"Opcode Not Implemented in AdjustSwitchTable"); } } @@ -759,7 +759,7 @@ RestorePredHash__( USES_REGS1 ) { PredHash = PtoPtoPredAdjust(PredHash); if (PredHash == NULL) { - Yap_Error(FATAL_ERROR,MkIntTerm(0),"restore should find predicate hash table"); + Yap_Error(SYSTEM_ERROR_FATAL,MkIntTerm(0),"restore should find predicate hash table"); } REINIT_RWLOCK(PredHashRWLock); RestoreHashPreds( PASS_REGS1 ); /* does most of the work */ @@ -1634,7 +1634,7 @@ RestoreEntries(PropEntry *pp, int int_key USES_REGS) break; default: /* OOPS */ - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "Invalid Atom Property %d at %p", pp->KindOfPE, pp); return; } diff --git a/JIT/HPP/JIT_Compiler.hpp b/JIT/HPP/JIT_Compiler.hpp index 3f76001fd..596418c88 100644 --- a/JIT/HPP/JIT_Compiler.hpp +++ b/JIT/HPP/JIT_Compiler.hpp @@ -58,7 +58,7 @@ #include "llvm/Analysis/BranchProbabilityInfo.h" #include "llvm/Analysis/RegionPrinter.h" #include "llvm/Support/MemoryBuffer.h" -//#include "llvm/Support/system_error.h" +//#include "llvm/Support/SYSTEM_ERROR_INTERNAL.h" #include "llvm/Support/Process.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Transforms/IPO.h" diff --git a/JIT/HPP/indexing_std.h b/JIT/HPP/indexing_std.h index 45d444978..e9f9a5da0 100644 --- a/JIT/HPP/indexing_std.h +++ b/JIT/HPP/indexing_std.h @@ -1257,7 +1257,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ diff --git a/JIT/HPP/indexing_std_d.h b/JIT/HPP/indexing_std_d.h index fca6fca97..a114131c2 100644 --- a/JIT/HPP/indexing_std_d.h +++ b/JIT/HPP/indexing_std_d.h @@ -1290,7 +1290,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ diff --git a/JIT/HPP/p_functor.i b/JIT/HPP/p_functor.i index e9be65ec2..d4d7fa145 100644 --- a/JIT/HPP/p_functor.i +++ b/JIT/HPP/p_functor.i @@ -180,7 +180,7 @@ if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { \ saveregs(); \ if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP((*_PREG),e),Osbmp))) { \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); \ break; \ @@ -259,7 +259,7 @@ if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { \ saveregs(); \ if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP((*_PREG),e),Osbmp))) { \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); \ break; \ @@ -345,7 +345,7 @@ if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { \ saveregs(); \ if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP((*_PREG),e),Osbmp))) { \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); \ break; \ @@ -424,7 +424,7 @@ if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { \ saveregs(); \ if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP((*_PREG),e),Osbmp))) { \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); \ break; \ @@ -744,7 +744,7 @@ if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { \ saveregs(); \ if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP((*_PREG),e),Osbmp))) { \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); \ break; \ @@ -823,7 +823,7 @@ if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { \ saveregs(); \ if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP((*_PREG),e),Osbmp))) { \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); \ break; \ @@ -909,7 +909,7 @@ if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { \ saveregs(); \ if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP((*_PREG),e),Osbmp))) { \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); \ break; \ @@ -988,7 +988,7 @@ if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { \ saveregs(); \ if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP((*_PREG),e),Osbmp))) { \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); \ break; \ diff --git a/JIT/HPP/singlecode_misc.h b/JIT/HPP/singlecode_misc.h index d52063b04..9e11c19b9 100644 --- a/JIT/HPP/singlecode_misc.h +++ b/JIT/HPP/singlecode_misc.h @@ -71,12 +71,12 @@ SET_ASP(YREG, E_CB*sizeof(CELL)); \ saveregs(); \ while ((t = Yap_FetchTermFromDB(cl->ClSource)) == 0L) { \ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { \ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { \ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_growglobal(NULL)) { \ UNLOCKPE(3,PP); \ PP = NULL; \ - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -85,7 +85,7 @@ if (!Yap_gc(3, ENV, CP)) { \ UNLOCKPE(4,PP); \ PP = NULL; \ - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -125,12 +125,12 @@ SET_ASP(YREG, E_CB*sizeof(CELL)); \ saveregs(); \ while ((t = Yap_FetchTermFromDB(cl->ClSource)) == 0L) { \ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { \ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { \ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_growglobal(NULL)) { \ UNLOCKPE(3,PP); \ PP = NULL; \ - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -139,7 +139,7 @@ if (!Yap_gc(3, ENV, CP)) { \ UNLOCKPE(4,PP); \ PP = NULL; \ - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); \ YAAM_FAIL; tofail = 1; \ break; \ } \ @@ -180,12 +180,12 @@ SET_ASP(YREG, E_CB*sizeof(CELL)); \ saveregs(); \ while ((t = Yap_FetchTermFromDB(cl->ClSource)) == 0L) { \ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { \ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { \ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_growglobal(NULL)) { \ UNLOCKPE(3,PP); \ PP = NULL; \ - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -194,7 +194,7 @@ if (!Yap_gc(3, ENV, CP)) { \ UNLOCKPE(4,PP); \ PP = NULL; \ - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -234,12 +234,12 @@ SET_ASP(YREG, E_CB*sizeof(CELL)); \ saveregs(); \ while ((t = Yap_FetchTermFromDB(cl->ClSource)) == 0L) { \ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { \ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { \ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_growglobal(NULL)) { \ UNLOCKPE(3,PP); \ PP = NULL; \ - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -248,7 +248,7 @@ if (!Yap_gc(3, ENV, CP)) { \ UNLOCKPE(4,PP); \ PP = NULL; \ - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -291,11 +291,11 @@ SET_ASP(YREG, E_CB*sizeof(CELL)); \ saveregs(); \ while ((t = Yap_FetchTermFromDB(cl->ClSource)) == 0L) { \ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { \ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { \ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_growglobal(NULL)) { \ UNLOCKPE(3,PP); \ - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -303,7 +303,7 @@ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_gc(3, ENV, CP)) { \ UNLOCKPE(4,PP); \ - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -341,11 +341,11 @@ SET_ASP(YREG, E_CB*sizeof(CELL)); \ saveregs(); \ while ((t = Yap_FetchTermFromDB(cl->ClSource)) == 0L) { \ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { \ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { \ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_growglobal(NULL)) { \ UNLOCKPE(3,PP); \ - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -353,7 +353,7 @@ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_gc(3, ENV, CP)) { \ UNLOCKPE(4,PP); \ - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -392,11 +392,11 @@ SET_ASP(YREG, E_CB*sizeof(CELL)); \ saveregs(); \ while ((t = Yap_FetchTermFromDB(cl->ClSource)) == 0L) { \ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { \ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { \ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_growglobal(NULL)) { \ UNLOCKPE(3,PP); \ - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -404,7 +404,7 @@ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_gc(3, ENV, CP)) { \ UNLOCKPE(4,PP); \ - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -442,11 +442,11 @@ SET_ASP(YREG, E_CB*sizeof(CELL)); \ saveregs(); \ while ((t = Yap_FetchTermFromDB(cl->ClSource)) == 0L) { \ - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { \ + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { \ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_growglobal(NULL)) { \ UNLOCKPE(3,PP); \ - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -454,7 +454,7 @@ LOCAL_Error_TYPE = YAP_NO_ERROR; \ if (!Yap_gc(3, ENV, CP)) { \ UNLOCKPE(4,PP); \ - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); \ YAAM_FAIL; \ break; \ } \ @@ -557,7 +557,7 @@ saveregs(); #define ENSURE_SPACE_SECONDIFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ FAIL(); diff --git a/JIT/HPP/singlecode_primitive_predicates.h b/JIT/HPP/singlecode_primitive_predicates.h index 76e92e25b..58a3e5f9d 100644 --- a/JIT/HPP/singlecode_primitive_predicates.h +++ b/JIT/HPP/singlecode_primitive_predicates.h @@ -3671,7 +3671,7 @@ if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { \ saveregs(); \ if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP((*_PREG),e),Osbmp))) { \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ BACK(); \ } else { \ @@ -3824,7 +3824,7 @@ if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { \ saveregs(); \ if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP((*_PREG),e),Osbmp))) { \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ BACK(); \ } else { \ diff --git a/JIT/HPP/traced_absmi_insts.i b/JIT/HPP/traced_absmi_insts.i index 421ecd646..702ad72be 100644 --- a/JIT/HPP/traced_absmi_insts.i +++ b/JIT/HPP/traced_absmi_insts.i @@ -357,7 +357,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -386,7 +386,7 @@ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { ENV = B->cp_env; saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -425,7 +425,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -472,7 +472,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -510,7 +510,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -557,7 +557,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -745,14 +745,14 @@ SET_ASP(YREG, E_CB*sizeof(CELL)); saveregs(); while ((t = Yap_FetchTermFromDB(cl->ClSource)) == 0L) { - if (LOCAL_Error_TYPE == OUT_OF_ATTVARS_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_ATTRIBUTED_VARIABLES) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growglobal(NULL)) { UNLOCKPE(3,PP); #if defined(YAPOR) || defined(THREADS) PP = NULL; #endif - Yap_NilError(OUT_OF_ATTVARS_ERROR, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, LOCAL_ErrorMessage); TRACED_FAIL(); } } else { @@ -762,7 +762,7 @@ #if defined(YAPOR) || defined(THREADS) PP = NULL; #endif - Yap_NilError(OUT_OF_STACK_ERROR, LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK, LOCAL_ErrorMessage); TRACED_FAIL(); } } @@ -886,7 +886,7 @@ PREG = NEXTOP(PREG,Osbpa); saveregs(); if (!Yap_gcl(sz, arity, YENV, PREG)) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); TRACED_FAIL(); } else { @@ -993,7 +993,7 @@ LOCAL_PredEntriesCounter--; if (LOCAL_PredEntriesCounter == 0) { saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -7159,7 +7159,7 @@ ///#endif UNLOCKPE(21,pe); saveregs(); - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); setregs(); JMPNext(); } @@ -12854,7 +12854,7 @@ ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_VV_SECONDIFOK_FIRSTIFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -13035,7 +13035,7 @@ ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_CV_D1GREATER_IFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -13200,7 +13200,7 @@ ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_VC_IFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -13368,7 +13368,7 @@ ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_Y_VV_D1GREATER_IFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -13559,7 +13559,7 @@ ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_Y_CV_D1GREATER_IFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -13745,7 +13745,7 @@ ///#ifdef PROFILED_ABSMI EMIT_SIMPLE_BLOCK(P_FUNC2S_Y_VC_IFOK_IFOK); ///#endif - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -14243,7 +14243,7 @@ /* make sure we have something to show for our trouble */ saveregs(); if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP(PREG,e),Osbmp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); setregs(); JMPNext(); } else { @@ -14491,7 +14491,7 @@ } saveregs_and_ycache(); if (!Yap_gc(((PredEntry *)SREG)->ArityOfPE, ENV, NEXTOP(PREG, Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); } setregs_and_ycache(); goto traced_execute2_end; @@ -14699,7 +14699,7 @@ } saveregs_and_ycache(); if (!Yap_gc(((PredEntry *)SREG)->ArityOfPE, ENV, NEXTOP(PREG, Osbmp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); } setregs_and_ycache(); goto traced_execute_end; @@ -14931,7 +14931,7 @@ UNLOCK(LOCAL_SignalLock); saveregs_and_ycache(); if (!Yap_growheap(FALSE, 0, NULL)) { - Yap_NilError(OUT_OF_HEAP_ERROR, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_HEAP, "YAP failed to grow heap: %s", LOCAL_ErrorMessage); setregs_and_ycache(); TRACED_FAIL(); } @@ -14951,7 +14951,7 @@ #endif saveregs_and_ycache(); if(!Yap_growtrail (0, FALSE)) { - Yap_NilError(OUT_OF_TRAIL_ERROR,"YAP failed to reserve %ld bytes in growtrail",sizeof(CELL) * K16); + Yap_NilError(RESOURCE_ERROR_TRAIL,"YAP failed to reserve %ld bytes in growtrail",sizeof(CELL) * K16); setregs_and_ycache(); TRACED_FAIL(); } @@ -14975,7 +14975,7 @@ UNLOCK(LOCAL_SignalLock); saveregs_and_ycache(); if (!Yap_gc(((PredEntry *)SREG)->ArityOfPE, ENV, NEXTOP(PREG, Osbpp))) { - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); } setregs_and_ycache(); goto traced_execute_after_comma; diff --git a/JIT/HPP/yaam_call_count.h b/JIT/HPP/yaam_call_count.h index c3fa11c04..b1cbb59af 100644 --- a/JIT/HPP/yaam_call_count.h +++ b/JIT/HPP/yaam_call_count.h @@ -15,7 +15,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -44,7 +44,7 @@ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { \ ENV = B->cp_env; \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -78,7 +78,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -100,7 +100,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -141,7 +141,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -170,7 +170,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -196,7 +196,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -219,7 +219,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -258,7 +258,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -297,7 +297,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -337,7 +337,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -375,7 +375,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -418,7 +418,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -489,7 +489,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -561,7 +561,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -626,7 +626,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -695,7 +695,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -769,7 +769,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -844,7 +844,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -912,7 +912,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -983,7 +983,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -1056,7 +1056,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -1130,7 +1130,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -1197,7 +1197,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ diff --git a/JIT/HPP/yaam_call_count_d.h b/JIT/HPP/yaam_call_count_d.h index 6e79b9beb..acc081f5b 100644 --- a/JIT/HPP/yaam_call_count_d.h +++ b/JIT/HPP/yaam_call_count_d.h @@ -16,7 +16,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -46,7 +46,7 @@ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { \ ENV = B->cp_env; \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -81,7 +81,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -103,7 +103,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0 && LOCAL_PredEntriesCounterOn) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -145,7 +145,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -174,7 +174,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -200,7 +200,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -223,7 +223,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } @@ -263,7 +263,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -303,7 +303,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -344,7 +344,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -383,7 +383,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -427,7 +427,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -499,7 +499,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -572,7 +572,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -638,7 +638,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -708,7 +708,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -783,7 +783,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -859,7 +859,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -928,7 +928,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -1000,7 +1000,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -1074,7 +1074,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -1149,7 +1149,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ @@ -1217,7 +1217,7 @@ LOCAL_PredEntriesCounter--; \ if (LOCAL_PredEntriesCounter == 0) { \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); \ } \ diff --git a/JIT/HPP/yaam_misc.h b/JIT/HPP/yaam_misc.h index 2bd792508..da85150d0 100644 --- a/JIT/HPP/yaam_misc.h +++ b/JIT/HPP/yaam_misc.h @@ -1174,7 +1174,7 @@ #define SPY_PRED_SECONDIFOK_SECONDIFOK \ UNLOCKPE(21,pe); \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); diff --git a/JIT/HPP/yaam_misc_d.h b/JIT/HPP/yaam_misc_d.h index 60f9eff75..e3d471c9f 100644 --- a/JIT/HPP/yaam_misc_d.h +++ b/JIT/HPP/yaam_misc_d.h @@ -1213,7 +1213,7 @@ #define SPY_PRED_SECONDIFOK_SECONDIFOK \ UNLOCKPE(21,pe); \ saveregs(); \ - Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW,""); \ + Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT,""); \ setregs(); \ JMPNext(); diff --git a/JIT/HPP/yaam_primitive_predicates.h b/JIT/HPP/yaam_primitive_predicates.h index 0a8edd300..c1706e2e1 100644 --- a/JIT/HPP/yaam_primitive_predicates.h +++ b/JIT/HPP/yaam_primitive_predicates.h @@ -2390,7 +2390,7 @@ saveregs(); #define P_FUNC2S_VV_SECONDIFOK_FIRSTIFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); @@ -2489,7 +2489,7 @@ saveregs(); #define P_FUNC2S_CV_D1GREATER_IFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); @@ -2583,7 +2583,7 @@ saveregs(); #define P_FUNC2S_VC_IFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); @@ -2674,7 +2674,7 @@ saveregs(); #define P_FUNC2S_Y_VV_D1GREATER_IFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); @@ -2776,7 +2776,7 @@ saveregs(); #define P_FUNC2S_Y_CV_D1GREATER_IFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); @@ -2880,7 +2880,7 @@ saveregs(); #define P_FUNC2S_Y_VC_IFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); diff --git a/JIT/HPP/yaam_primitive_predicates_d.h b/JIT/HPP/yaam_primitive_predicates_d.h index c364c362f..82f733658 100644 --- a/JIT/HPP/yaam_primitive_predicates_d.h +++ b/JIT/HPP/yaam_primitive_predicates_d.h @@ -2457,7 +2457,7 @@ saveregs(); #define P_FUNC2S_VV_SECONDIFOK_FIRSTIFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); @@ -2557,7 +2557,7 @@ saveregs(); #define P_FUNC2S_CV_D1GREATER_IFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); @@ -2652,7 +2652,7 @@ saveregs(); #define P_FUNC2S_VC_IFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); @@ -2744,7 +2744,7 @@ saveregs(); #define P_FUNC2S_Y_VV_D1GREATER_IFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); @@ -2847,7 +2847,7 @@ saveregs(); #define P_FUNC2S_Y_CV_D1GREATER_IFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); @@ -2952,7 +2952,7 @@ saveregs(); #define P_FUNC2S_Y_VC_IFOK_IFOK \ - Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); \ + Yap_NilError(RESOURCE_ERROR_STACK,LOCAL_ErrorMessage); \ setregs(); \ JMPNext(); diff --git a/JIT/jit_traced.c b/JIT/jit_traced.c index 249b208dc..a0888143d 100644 --- a/JIT/jit_traced.c +++ b/JIT/jit_traced.c @@ -225,7 +225,7 @@ CACHE_A1(); cut_b = LCL0-(CELL *)(ASP[E_CB]); saveregs(); if(!Yap_growtrail (0, false)) { - Yap_NilError(OUT_OF_TRAIL_ERROR,"YAP failed to reserve %ld bytes in growtrail",sizeof(CELL) * K16); + Yap_NilError(RESOURCE_ERROR_TRAIL,"YAP failed to reserve %ld bytes in growtrail",sizeof(CELL) * K16); setregs(); FAIL(); } @@ -255,7 +255,7 @@ CACHE_A1(); #if _NATIVE default: saveregs(); - Yap_Error(SYSTEM_ERROR, MkIntegerTerm(opcode), "trying to execute invalid YAAM instruction %d", opcode); + Yap_Error(SYSTEM_ERROR_INTERNAL, MkIntegerTerm(opcode), "trying to execute invalid YAAM instruction %d", opcode); setregs(); FAIL(); } diff --git a/OPTYap/opt.macros.h b/OPTYap/opt.macros.h index 93a415bd7..333dbce89 100644 --- a/OPTYap/opt.macros.h +++ b/OPTYap/opt.macros.h @@ -56,7 +56,7 @@ extern size_t Yap_page_size; *******************************************************************************************/ #define ALLOC_BLOCK(STR, SIZE, STR_TYPE) \ if ((STR = (STR_TYPE *) malloc(SIZE)) == NULL) \ - Yap_Error(FATAL_ERROR, TermNil, "ALLOC_BLOCK: malloc error") + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "ALLOC_BLOCK: malloc error") #define FREE_BLOCK(STR) \ free(STR) #else @@ -70,7 +70,7 @@ extern size_t Yap_page_size; else if ((block_ptr = (char *) malloc(SIZE + sizeof(CELL))) != NULL) \ *block_ptr = 'm'; \ else \ - Yap_Error(FATAL_ERROR, TermNil, "ALLOC_BLOCK: malloc error"); \ + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "ALLOC_BLOCK: malloc error"); \ block_ptr += sizeof(CELL); \ STR = (STR_TYPE *) block_ptr; \ } @@ -244,11 +244,11 @@ extern size_t Yap_page_size; int shmid; \ void *mem_block; \ if ((shmid = shmget(IPC_PRIVATE, SHMMAX, SHM_R|SHM_W)) == -1) \ - Yap_Error(FATAL_ERROR, TermNil, "shmget error (ALLOC_PAGE)"); \ + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "shmget error (ALLOC_PAGE)"); \ if ((mem_block = shmat(shmid, NULL, 0)) == (void *) -1) \ - Yap_Error(FATAL_ERROR, TermNil, "shmat error (ALLOC_PAGE)"); \ + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "shmat error (ALLOC_PAGE)"); \ if (shmctl(shmid, IPC_RMID, 0) != 0) \ - Yap_Error(FATAL_ERROR, TermNil, "shmctl error (ALLOC_PAGE)"); \ + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "shmctl error (ALLOC_PAGE)"); \ PgEnt_first(GLOBAL_pages_alloc) = (pg_hd_ptr)(mem_block + Yap_page_size); \ PgEnt_last(GLOBAL_pages_alloc) = (pg_hd_ptr)(mem_block + SHMMAX); \ UPDATE_STATS(PgEnt_pages_in_use(GLOBAL_pages_alloc), SHMMAX / Yap_page_size); \ @@ -265,9 +265,9 @@ extern size_t Yap_page_size; else \ sg_fr = GLOBAL_first_sg_fr; \ if (sg_fr == NULL) \ - Yap_Error(FATAL_ERROR, TermNil, "no space left (RECOVER_SPACE)"); \ + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "no space left (RECOVER_SPACE)"); \ /* see function 'InteractSIGINT' in file 'sysbits.c' */ \ - /* Yap_Error(PURE_ABORT, TermNil, ""); */ \ + /* Yap_Error(PURE_ABORT_EVENT, TermNil, ""); */ \ /* restore_absmi_regs(&Yap_standard_regs); */ \ /* siglongjmp (LOCAL_RestartEnv, 1); */ \ if (SgFr_first_answer(sg_fr) && \ @@ -518,10 +518,10 @@ extern size_t Yap_page_size; #ifdef YAPOR #define ERROR_MESSAGE(MESSAGE) \ - Yap_Error(INTERNAL_ERROR, TermNil, "W%d - " MESSAGE, worker_id) + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "W%d - " MESSAGE, worker_id) #else #define ERROR_MESSAGE(MESSAGE) \ - Yap_Error(INTERNAL_ERROR, TermNil, MESSAGE) + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, MESSAGE) #endif /* YAPOR */ #ifdef DEBUG_TABLING diff --git a/OPTYap/opt.preds.c b/OPTYap/opt.preds.c index fd2ce8c26..a024de42a 100644 --- a/OPTYap/opt.preds.c +++ b/OPTYap/opt.preds.c @@ -312,7 +312,7 @@ static Int p_table( USES_REGS1 ) { return (FALSE); if (list != TermNil) { /* non-empty list */ #ifndef MODE_DIRECTED_TABLING - Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "invalid tabling declaration for %s/%d (mode directed tabling not enabled)", AtomName(at), arity); + Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "invalid tabling declaration for %s/%d (mode directed tabling not enabled)", AtomName(at), arity); return(FALSE); #else /************************************************************************************* @@ -343,7 +343,7 @@ static Int p_table( USES_REGS1 ) { else if (mode == MODE_DIRECTED_SUM || mode == MODE_DIRECTED_LAST) { if (pos_sum_last) { free(aux_mode_directed); - Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "invalid tabling declaration for %s/%d (more than one argument with modes 'sum' and/or 'last')", AtomName(at), arity); + Yap_Error(SYSTEM_ERROR_COMPILER, TermNil, "invalid tabling declaration for %s/%d (more than one argument with modes 'sum' and/or 'last')", AtomName(at), arity); return(FALSE); } else pos_sum_last = 1; diff --git a/OPTYap/or.copy_engine.c b/OPTYap/or.copy_engine.c index 0fe4c4c12..a45a68d8a 100644 --- a/OPTYap/or.copy_engine.c +++ b/OPTYap/or.copy_engine.c @@ -568,7 +568,7 @@ void share_private_nodes(int worker_q) { /* update depth */ if (depth >= MAX_BRANCH_DEPTH) - Yap_Error(INTERNAL_ERROR, TermNil, "maximum depth exceded (share_private_nodes)"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "maximum depth exceded (share_private_nodes)"); or_frame = B->cp_or_fr; #ifdef TABLING previous_or_frame = LOCAL_top_cp_on_stack->cp_or_fr; diff --git a/OPTYap/or.cow_engine.c b/OPTYap/or.cow_engine.c index a384581bc..9996db457 100644 --- a/OPTYap/or.cow_engine.c +++ b/OPTYap/or.cow_engine.c @@ -197,7 +197,7 @@ void share_private_nodes(int worker_q) { } /* update depth */ if (depth >= MAX_BRANCH_DEPTH) - Yap_Error(INTERNAL_ERROR, TermNil, "maximum depth exceded (share_private_nodes)"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "maximum depth exceded (share_private_nodes)"); or_frame = B->cp_or_fr; while (or_frame != LOCAL_top_or_fr) { unsigned int branch; diff --git a/OPTYap/or.memory.c b/OPTYap/or.memory.c index 529bc8da5..94cb7fade 100644 --- a/OPTYap/or.memory.c +++ b/OPTYap/or.memory.c @@ -66,21 +66,21 @@ void Yap_init_yapor_global_local_memory(void) { #ifdef MMAP_MEMORY_MAPPING_SCHEME { int fd_mapfile; if (getcwd(mapfile_path,PATH_MAX) == NULL) - Yap_Error(FATAL_ERROR, TermNil, "getcwd error (Yap_init_yapor_global_local_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "getcwd error (Yap_init_yapor_global_local_memory)"); strcat(mapfile_path,"/mapfile"); itos(getpid(), &mapfile_path[strlen(mapfile_path)]); if (strlen(mapfile_path) >= PATH_MAX) - Yap_Error(FATAL_ERROR, TermNil, "PATH_MAX error (Yap_init_yapor_global_local_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "PATH_MAX error (Yap_init_yapor_global_local_memory)"); if ((fd_mapfile = open(mapfile_path, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) - Yap_Error(FATAL_ERROR, TermNil, "open error (Yap_init_yapor_global_local_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "open error (Yap_init_yapor_global_local_memory)"); if (lseek(fd_mapfile, GLOBAL_LOCAL_STRUCTS_AREA, SEEK_SET) < 0) - Yap_Error(FATAL_ERROR, TermNil, "lseek error (Yap_init_yapor_global_local_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "lseek error (Yap_init_yapor_global_local_memory)"); if (write(fd_mapfile, "", 1) < 0) - Yap_Error(FATAL_ERROR, TermNil, "write error (Yap_init_yapor_global_local_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "write error (Yap_init_yapor_global_local_memory)"); if (mmap((void *) Yap_local, (size_t) GLOBAL_LOCAL_STRUCTS_AREA, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd_mapfile, 0) == (void *) -1) - Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_init_global_local_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "mmap error (Yap_init_global_local_memory)"); if (close(fd_mapfile) == -1) - Yap_Error(FATAL_ERROR, TermNil, "close error (Yap_init_yapor_global_local_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "close error (Yap_init_yapor_global_local_memory)"); } #elif defined(SHM_MEMORY_MAPPING_SCHEME) /* place as segment MAX_WORKERS (0..MAX_WORKERS-1 reserved for worker areas) */ @@ -114,15 +114,15 @@ void Yap_init_yapor_stacks_memory(UInt TrailStackArea, UInt HeapStackArea, UInt /* map stacks in a single go */ { int fd_mapfile; if ((fd_mapfile = open(mapfile_path, O_RDWR)) < 0) - Yap_Error(FATAL_ERROR, TermNil, "open error ( Yap_init_yapor_stacks_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "open error ( Yap_init_yapor_stacks_memory)"); if (lseek(fd_mapfile, GLOBAL_LOCAL_STRUCTS_AREA + StacksArea, SEEK_SET) < 0) - Yap_Error(FATAL_ERROR, TermNil, "lseek error (Yap_init_yapor_stacks_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "lseek error (Yap_init_yapor_stacks_memory)"); if (write(fd_mapfile, "", 1) < 0) - Yap_Error(FATAL_ERROR, TermNil, "write error (Yap_init_yapor_stacks_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "write error (Yap_init_yapor_stacks_memory)"); if (mmap((void *) Yap_HeapBase, (size_t) StacksArea, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd_mapfile, GLOBAL_LOCAL_STRUCTS_AREA) == (void *) -1) - Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_init_yapor_stacks_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "mmap error (Yap_init_yapor_stacks_memory)"); if (close(fd_mapfile) == -1) - Yap_Error(FATAL_ERROR, TermNil, "close error (Yap_init_yapor_stacks_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "close error (Yap_init_yapor_stacks_memory)"); } #elif defined(SHM_MEMORY_MAPPING_SCHEME) /* place heap stack segment as MAX_WORKERS+1 */ @@ -140,10 +140,10 @@ void Yap_init_yapor_stacks_memory(UInt TrailStackArea, UInt HeapStackArea, UInt /* just allocate local space for stacks */ { int private_fd_mapfile; if ((private_fd_mapfile = open("/dev/zero", O_RDWR)) < 0) - Yap_Error(FATAL_ERROR, TermNil, "open error (Yap_init_yapor_stacks_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "open error (Yap_init_yapor_stacks_memory)"); if (mmap(LOCAL_GlobalBase, Yap_worker_area_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, private_fd_mapfile, 0) == (void *) -1) - Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_init_yapor_stacks_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "mmap error (Yap_init_yapor_stacks_memory)"); close(private_fd_mapfile); } #endif /* YAPOR_COW */ @@ -152,9 +152,9 @@ void Yap_init_yapor_stacks_memory(UInt TrailStackArea, UInt HeapStackArea, UInt /* alloc space for the sparse binding array */ sba_size = Yap_worker_area_size * n_workers; if ((binding_array = (char *)malloc(sba_size)) == NULL) - Yap_Error(FATAL_ERROR, TermNil, "malloc error (Yap_init_yapor_stacks_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "malloc error (Yap_init_yapor_stacks_memory)"); if ((CELL)binding_array & MBIT) - Yap_Error(INTERNAL_ERROR, TermNil, "binding_array start address conflicts with tag used in IDB (Yap_init_yapor_stacks_memory)"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "binding_array start address conflicts with tag used in IDB (Yap_init_yapor_stacks_memory)"); sba_offset = binding_array - LOCAL_GlobalBase; sba_end = (int)binding_array + sba_size; #endif /* YAPOR_SBA */ @@ -176,22 +176,22 @@ void Yap_remap_yapor_memory(void) { int fd_mapfile; long remap_offset = (ADDR) remap_addr - (ADDR) Yap_local; if ((fd_mapfile = open(mapfile_path, O_RDWR)) < 0) - Yap_Error(FATAL_ERROR, TermNil, "open error (Yap_remap_yapor_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "open error (Yap_remap_yapor_memory)"); if (munmap(remap_addr, (size_t)(Yap_worker_area_size * GLOBAL_number_workers)) == -1) - Yap_Error(FATAL_ERROR, TermNil, "munmap error (Yap_remap_yapor_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "munmap error (Yap_remap_yapor_memory)"); for (i = 0; i < GLOBAL_number_workers; i++) if (mmap(remap_addr + worker_offset(i), (size_t)Yap_worker_area_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd_mapfile, remap_offset + i * Yap_worker_area_size) == (void *) -1) - Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_remap_yapor_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "mmap error (Yap_remap_yapor_memory)"); if (close(fd_mapfile) == -1) - Yap_Error(FATAL_ERROR, TermNil, "close error (Yap_remap_yapor_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "close error (Yap_remap_yapor_memory)"); #else /* SHM_MEMORY_MAPPING_SCHEME */ for (i = 0; i < GLOBAL_number_workers; i++) if (shmdt(remap_addr + Yap_worker_area_size * i) == -1) - Yap_Error(FATAL_ERROR, TermNil, "shmdt error (Yap_remap_yapor_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "shmdt error (Yap_remap_yapor_memory)"); for (i = 0; i < GLOBAL_number_workers; i++) if(shmat(shm_mapid[i], remap_addr + worker_offset(i), 0) == (void *) -1) - Yap_Error(FATAL_ERROR, TermNil, "shmat error (Yap_remap_yapor_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "shmat error (Yap_remap_yapor_memory)"); #endif /* MEMORY_MAPPING_SCHEME */ #elif defined(YAPOR_SBA) /* setup workers so that they have different areas */ @@ -250,9 +250,9 @@ void Yap_unmap_yapor_memory (void) { #ifdef SHM_MEMORY_MAPPING_SCHEME void shm_map_memory(int id, int size, void *shmaddr) { if ((shm_mapid[id] = shmget(IPC_PRIVATE, size, SHM_R|SHM_W)) == -1) - Yap_Error(FATAL_ERROR, TermNil, "shmget error (shm_map_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "shmget error (shm_map_memory)"); if (shmat(shm_mapid[id], shmaddr, 0) == (void *) -1) - Yap_Error(FATAL_ERROR, TermNil, "shmat error (shm_map_memory)"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "shmat error (shm_map_memory)"); return; } diff --git a/OPTYap/or.sba_engine.c b/OPTYap/or.sba_engine.c index 6713ebedd..2932457a4 100644 --- a/OPTYap/or.sba_engine.c +++ b/OPTYap/or.sba_engine.c @@ -262,7 +262,7 @@ void share_private_nodes(int worker_q) { } /* update depth */ if (depth >= MAX_BRANCH_DEPTH) - Yap_Error(INTERNAL_ERROR, TermNil, "maximum depth exceded (share_private_nodes)"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "maximum depth exceded (share_private_nodes)"); or_frame = B->cp_or_fr; while (or_frame != LOCAL_top_or_fr) { diff --git a/OPTYap/or.thread_engine.c b/OPTYap/or.thread_engine.c index c9a95574b..87c82562e 100644 --- a/OPTYap/or.thread_engine.c +++ b/OPTYap/or.thread_engine.c @@ -432,7 +432,7 @@ void share_private_nodes(int worker_q) { /* update depth */ if (depth >= MAX_BRANCH_DEPTH) - Yap_Error(INTERNAL_ERROR, TermNil, "maximum depth exceded (share_private_nodes)"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "maximum depth exceded (share_private_nodes)"); or_frame = B->cp_or_fr; #ifdef TABLING previous_or_frame = Get_LOCAL_top_cp_on_stack()->cp_or_fr; diff --git a/OPTYap/tab.macros.h b/OPTYap/tab.macros.h index 8fd311f85..290246e6d 100644 --- a/OPTYap/tab.macros.h +++ b/OPTYap/tab.macros.h @@ -235,7 +235,7 @@ typedef enum { #if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) #define AUX_STACK_CHECK_EXPAND(STACK, STACK_LIMIT) \ if ((STACK_LIMIT) >= (STACK)) \ - Yap_Error(INTERNAL_ERROR, TermNil, "stack full (AUX_STACK_CHECK_EXPAND)") + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "stack full (AUX_STACK_CHECK_EXPAND)") #else /* YAPOR_THREADS */ #define AUX_STACK_CHECK_EXPAND(STACK, STACK_LIMIT) \ if ((STACK_LIMIT) >= (STACK)) \ @@ -243,7 +243,7 @@ typedef enum { #endif /* YAPOR */ #define STACK_CHECK_EXPAND(STACK, STACK_LIMIT) \ if ((STACK_LIMIT) >= (STACK) + 4096) \ - Yap_Error(INTERNAL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)") + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "stack full (STACK_CHECK_EXPAND)") @@ -1238,7 +1238,7 @@ static inline CELL *__expand_auxiliary_stack(CELL *stack USES_REGS) { char *old_top = (char *)LOCAL_TrailTop; INFORMATION_MESSAGE("Expanding trail in " UInt_FORMAT " bytes", K64); if (! Yap_growtrail(K64, TRUE)) { /* TRUE means 'contiguous_only' */ - Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)"); + Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, "stack full (STACK_CHECK_EXPAND)"); return NULL; } else { UInt diff = (char *)LOCAL_TrailTop - old_top; @@ -1399,7 +1399,7 @@ static inline void __abolish_incomplete_subgoals(choiceptr prune_cp USES_REGS) { #ifdef YAPOR static inline void pruning_over_tabling_data_structures(void) { - Yap_Error(INTERNAL_ERROR, TermNil, "pruning over tabling data structures"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "pruning over tabling data structures"); return; } diff --git a/OPTYap/tab.rational.h b/OPTYap/tab.rational.h index 907137865..d67a58317 100644 --- a/OPTYap/tab.rational.h +++ b/OPTYap/tab.rational.h @@ -32,11 +32,11 @@ void term_array_init(term_array *array, int capacity) { if (array->terms != NULL) { array->capacity = capacity; } else - Yap_Error(RESOURCE_ERROR_MEMORY, TermNil, "Out of memory."); // Handle out-of-memory + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "Out of memory."); // Handle out-of-memory array->capacity = capacity; array->nodes = malloc(capacity * sizeof(void*)); if (array->nodes == NULL) - Yap_Error(RESOURCE_ERROR_MEMORY, TermNil, "Out of memory."); // Handle out-of-memory + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "Out of memory."); // Handle out-of-memory } void term_array_free(term_array *array) { @@ -55,12 +55,12 @@ void term_array_push(term_array *array, void* t, void* n) { if (new_terms != NULL) { array->terms = new_terms; } else - Yap_Error(RESOURCE_ERROR_MEMORY, TermNil, "Out of memory."); // Handle out-of-memory + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "Out of memory."); // Handle out-of-memory void *new_nodes = realloc(array->nodes, new_capacity * sizeof(void *)); if (new_nodes != NULL) { array->nodes = new_nodes; } else - Yap_Error(RESOURCE_ERROR_MEMORY, TermNil, "Out of memory."); // Handle out-of-memory + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "Out of memory."); // Handle out-of-memory array->capacity = new_capacity; } array->terms[array->length] = t; diff --git a/OPTYap/tab.tries.c b/OPTYap/tab.tries.c index c65a1871f..39ff91f2b 100644 --- a/OPTYap/tab.tries.c +++ b/OPTYap/tab.tries.c @@ -1263,7 +1263,7 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) { } else if (mode == MODE_DIRECTED_FIRST) { current_ans_node = NULL; } else - Yap_Error(INTERNAL_ERROR, TermNil, "mode_directed_answer_search: unknown mode"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "mode_directed_answer_search: unknown mode"); UNLOCK_ANSWER_NODE(current_ans_node); } n_subs--; @@ -1679,7 +1679,7 @@ void showTable(tab_ent_ptr tab_ent, int show_mode, FILE *out) { } else if (mode == MODE_DIRECTED_FIRST) { fprintf(TrStat_out, "first"); } else - Yap_Error(INTERNAL_ERROR, TermNil, "show_table: unknown mode"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "show_table: unknown mode"); if (i != MODE_DIRECTED_GET_ARG(mode_directed[i])) fprintf(TrStat_out, "(ARG%d)", MODE_DIRECTED_GET_ARG(mode_directed[i]) + 1); if (i + 1 != TabEnt_arity(tab_ent)) diff --git a/OPTYap/tab.tries.h b/OPTYap/tab.tries.h index 3c7eea8ce..7d825a532 100644 --- a/OPTYap/tab.tries.h +++ b/OPTYap/tab.tries.h @@ -1062,7 +1062,7 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c SUBGOAL_CHECK_INSERT_ENTRY(tab_ent, current_node, t); } else { if (subs_arity == MAX_TABLE_VARS) - Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop: MAX_TABLE_VARS exceeded"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "subgoal_search_loop: MAX_TABLE_VARS exceeded"); STACK_PUSH_UP(t, stack_vars); *((CELL *)t) = GLOBAL_table_var_enumerator(subs_arity); t = MakeTableVarTerm(subs_arity); @@ -1230,7 +1230,7 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c SUBGOAL_CHECK_INSERT_ENTRY(tab_ent, current_node, AbsAppl((Term *)f)); #endif /* MODE_GLOBAL_TRIE_LOOP */ } else if (f == FunctorDBRef) { - Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop: unsupported type tag FunctorDBRef"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "subgoal_search_loop: unsupported type tag FunctorDBRef"); } else { #ifdef TRIE_RATIONAL_TERMS term_array_push(&Ts, (void *) t, (void *) current_node); @@ -1253,7 +1253,7 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c } } } else { - Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop: unknown type tag"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "subgoal_search_loop: unknown type tag"); #endif /* MODE_TERMS_LOOP */ } t = STACK_POP_DOWN(stack_terms); @@ -1352,7 +1352,7 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, t, _trie_retry_val + in_pair); } else { if (vars_arity == MAX_TABLE_VARS) - Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop: MAX_TABLE_VARS exceeded"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "answer_search_loop: MAX_TABLE_VARS exceeded"); stack_vars_base[vars_arity] = t; *((CELL *)t) = GLOBAL_table_var_enumerator(vars_arity); t = MakeTableVarTerm(vars_arity); @@ -1525,7 +1525,7 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, (CELL)opq, _trie_retry_extension); ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, AbsAppl((Term *)f), _trie_retry_bigint); } else if (f == FunctorDBRef) { - Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop: unsupported type tag FunctorDBRef"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "answer_search_loop: unsupported type tag FunctorDBRef"); } else { #ifdef TRIE_RATIONAL_TERMS term_array_push(&Ts, (void *) t, (void *) current_node); @@ -1551,7 +1551,7 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr in_pair = 0; #endif /* TRIE_COMPACT_PAIRS */ } else { - Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop: unknown type tag"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "answer_search_loop: unknown type tag"); #endif /* MODE_TERMS_LOOP */ } t = STACK_POP_DOWN(stack_terms); @@ -1606,7 +1606,7 @@ static inline ans_node_ptr answer_search_min_max(sg_fr_ptr sg_fr, ans_node_ptr c } else if (f == FunctorBigInt) { trie_value = AbsAppl( (CELL *) TrNode_entry(child_node) ); } else - Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_min_max: invalid arithmetic value"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "answer_search_min_max: invalid arithmetic value"); child_node = TrNode_child(child_node); } @@ -1686,7 +1686,7 @@ static inline ans_node_ptr answer_search_sum(sg_fr_ptr sg_fr, ans_node_ptr curre } else if (f == FunctorBigInt) { trie_value = AbsAppl( (CELL *) TrNode_entry(child_node) ); } else - Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_min_max: invalid arithmetic value"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "answer_search_min_max: invalid arithmetic value"); child_node = TrNode_child(child_node); } @@ -1911,7 +1911,7 @@ static inline CELL *load_answer_loop(ans_node_ptr current_node USES_REGS) { Term head, tail = STACK_POP_UP(stack_aux); #ifdef TRIE_RATIONAL_TERMS if (IsRationalTerm(tail)) { - Yap_Error(INTERNAL_ERROR, tail, "Rational element of a Rational Term appears as the first Tail of a list"); + Yap_Error(SYSTEM_ERROR_INTERNAL, tail, "Rational element of a Rational Term appears as the first Tail of a list"); } #endif /* RATIONAL TERM SUPPORT FOR TRIES */ while (STACK_NOT_EMPTY(stack_aux, stack_terms)) { diff --git a/OPTYap/tab.tries.insts.h b/OPTYap/tab.tries.insts.h index 4ffde41b4..6cef8eeea 100644 --- a/OPTYap/tab.tries.insts.h +++ b/OPTYap/tab.tries.insts.h @@ -465,7 +465,7 @@ aux_stack_var_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_var_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_do_var_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -481,7 +481,7 @@ pop_trie_node(); aux_stack_var_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_var_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_var_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -497,7 +497,7 @@ store_trie_node(TrNode_next(node)); aux_stack_var_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_var_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_var_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -513,7 +513,7 @@ restore_trie_node(TrNode_next(node)); aux_stack_var_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_var_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_var_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -580,7 +580,7 @@ aux_stack_val_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_val_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_do_val_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -597,7 +597,7 @@ pop_trie_node(); aux_stack_val_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_val_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_val_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -614,7 +614,7 @@ store_trie_node(TrNode_next(node)); aux_stack_val_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_val_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_val_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -631,7 +631,7 @@ restore_trie_node(TrNode_next(node)); aux_stack_val_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_val_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_val_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -697,7 +697,7 @@ aux_stack_term_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_atom_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_do_atom_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -713,7 +713,7 @@ pop_trie_node(); aux_stack_term_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_atom_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_atom_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -729,7 +729,7 @@ store_trie_node(TrNode_next(node)); aux_stack_term_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_atom_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_atom_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -745,7 +745,7 @@ restore_trie_node(TrNode_next(node)); aux_stack_term_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_atom_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_atom_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -803,7 +803,7 @@ aux_stack_new_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_null_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_do_null_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -819,7 +819,7 @@ pop_trie_node(); aux_stack_new_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_null_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_null_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -835,7 +835,7 @@ store_trie_node(TrNode_next(node)); aux_stack_new_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_null_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_null_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -851,7 +851,7 @@ restore_trie_node(TrNode_next(node)); aux_stack_new_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_null_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_null_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -970,7 +970,7 @@ aux_stack_appl_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_do_appl_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_do_appl_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -988,7 +988,7 @@ pop_trie_node(); aux_stack_appl_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_appl_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_appl_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -1006,7 +1006,7 @@ store_trie_node(TrNode_next(node)); aux_stack_appl_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_appl_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_appl_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -1024,7 +1024,7 @@ restore_trie_node(TrNode_next(node)); aux_stack_appl_in_pair_instr(); #else - Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_appl_in_pair: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_appl_in_pair: invalid instruction"); #endif /* TRIE_COMPACT_PAIRS */ ENDPBOp(); @@ -1103,17 +1103,17 @@ BOp(trie_trust_double, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_double: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_double: invalid instruction"); ENDBOp(); BOp(trie_try_double, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_double: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_double: invalid instruction"); ENDBOp(); BOp(trie_retry_double, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_double: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_double: invalid instruction"); ENDBOp(); @@ -1133,17 +1133,17 @@ BOp(trie_trust_longint, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_longint: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_longint: invalid instruction"); ENDBOp(); BOp(trie_try_longint, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_longint: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_longint: invalid instruction"); ENDBOp(); BOp(trie_retry_longint, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_longint: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_longint: invalid instruction"); ENDBOp(); @@ -1163,17 +1163,17 @@ BOp(trie_trust_bigint, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_bigint: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_bigint: invalid instruction"); ENDBOp(); BOp(trie_try_bigint, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_bigint: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_bigint: invalid instruction"); ENDBOp(); BOp(trie_retry_bigint, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_bigint: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_bigint: invalid instruction"); ENDBOp(); diff --git a/OPTYap/traced_tab.tries.insts.h b/OPTYap/traced_tab.tries.insts.h index 8931d7bb6..2c8ac324d 100644 --- a/OPTYap/traced_tab.tries.insts.h +++ b/OPTYap/traced_tab.tries.insts.h @@ -679,17 +679,17 @@ ENDPBOp(); BOp(trie_trust_double, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_double: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_double: invalid instruction"); ENDBOp(); BOp(trie_try_double, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_double: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_double: invalid instruction"); ENDBOp(); BOp(trie_retry_double, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_retry_double: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_retry_double: invalid instruction"); ENDBOp(); @@ -710,12 +710,12 @@ ENDPBOp(); BOp(trie_trust_longint, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_trust_longint: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_trust_longint: invalid instruction"); ENDBOp(); BOp(trie_try_longint, e) - Yap_Error(INTERNAL_ERROR, TermNil, "trie_try_longint: invalid instruction"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "trie_try_longint: invalid instruction"); ENDBOp(); diff --git a/build-distr b/build-distr deleted file mode 100644 index b92f9395d..000000000 --- a/build-distr +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# -# small but nasty script to build a new YAP release from the current -# directory: it first builds a new tar file, next creates -# rpms, and last creates a new web page directory. -# - -YAP_DIR=`pwd` -PAGE_DIR=~vitor/lpublic_html/Yap/Yap4.3 -OWNER=vitor -parent=$(cd ..;pwd) -version=${PWD##$parent/} - -splat() { - rm -f core - for i in *.tex; do - rm -f ${i%.tex}.aux - rm -f ${i%.tex}.log - rm -f ${i%.tex}.dvi - rm -f ${i%.tex}.bbl - rm -f ${i%.tex}.blg -# get rid of outputs from original file. - rm -f ${i%.tex}.ps - done - rm -f *~ - rm -f *.BAK - rm -f \#*\# -} - -. distribute --small -cp $YAP_DIR/../"$version".tar.gz $PAGE_DIR/"$version"-small.tar.gz -cd /usr/src/RPM/SPECS -cp $YAP_DIR/misc/Yap.spec . -mv $YAP_DIR/../"$version".tar.gz ../SOURCES -rpm -ba Yap.spec -cd /usr/src/RPM -mv SRPMS/Yap* $PAGE_DIR -mv RPMS/*/Yap* $PAGE_DIR -rm -rf BUILD/Yap* -rm -rf SOURCES/Yap* -rm -rf SPECS/Yap* -cd $YAP_DIR -# get rid of silly $1 -shift -. distribute -mv -f $YAP_DIR/../"$version".tar.gz $PAGE_DIR -cp -f $YAP_DIR/changes4.3.html $PAGE_DIR -cd $YAP_DIR/docs -make html -cd $YAP_DIR -cp -f $YAP_DIR/docs/*.html $PAGE_DIR -chown $OWNER $PAGE_DIR/* -chmod 666 $PAGE_DIR/* - diff --git a/cmake/FindLLVM.cmake b/cmake/FindLLVM.cmake index c6321d2bd..4a364f9ff 100644 --- a/cmake/FindLLVM.cmake +++ b/cmake/FindLLVM.cmake @@ -62,7 +62,7 @@ if ((WIN32 AND NOT(MINGW OR CYGWIN)) OR NOT LLVM_CONFIG) if (WIN32) # A bit of a sanity check: if( NOT EXISTS ${LLVM_ROOT_DIR}/include/llvm ) - message(FATAL_ERROR "LLVM_ROOT_DIR (${LLVM_ROOT_DIR}) is not a valid LLVM install") + message(SYSTEM_ERROR_FATAL "LLVM_ROOT_DIR (${LLVM_ROOT_DIR}) is not a valid LLVM install") endif() # We incorporate the CMake features provided by LLVM: set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT_DIR}/share/llvm/cmake") diff --git a/cmake/FindMySQL.cmake b/cmake/FindMySQL.cmake index 233d3ea97..0f2ec5e6d 100644 --- a/cmake/FindMySQL.cmake +++ b/cmake/FindMySQL.cmake @@ -37,7 +37,7 @@ IF (MYSQL_FOUND) ELSE (MYSQL_FOUND) IF (MYSQL_FIND_REQUIRED) MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.") - MESSAGE(FATAL_ERROR "Could NOT find MySQL library") + MESSAGE(SYSTEM_ERROR_FATAL "Could NOT find MySQL library") ENDIF (MYSQL_FIND_REQUIRED) ENDIF (MYSQL_FOUND) diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake index 18c42911e..74f457c8b 100644 --- a/cmake/FindReadline.cmake +++ b/cmake/FindReadline.cmake @@ -81,6 +81,6 @@ IF(READLINE_FOUND) MESSAGE(STATUS "Found readline library") ELSE(READLINE_FOUND) IF(READLINE_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find readline -- please give some paths to CMake") + MESSAGE(SYSTEM_ERROR_FATAL "Could not find readline -- please give some paths to CMake") ENDIF(READLINE_FIND_REQUIRED) ENDIF(READLINE_FOUND) diff --git a/cmake/FindSqlite3.cmake b/cmake/FindSqlite3.cmake index 24654cfe4..b505f6810 100644 --- a/cmake/FindSqlite3.cmake +++ b/cmake/FindSqlite3.cmake @@ -91,7 +91,7 @@ else (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) endif (NOT Sqlite3_FIND_QUIETLY) else (SQLITE3_FOUND) if (Sqlite3_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Sqlite3") + message(SYSTEM_ERROR_FATAL "Could not find Sqlite3") endif (Sqlite3_FIND_REQUIRED) endif (SQLITE3_FOUND) diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake index c8d27f2e8..68ad5db63 100644 --- a/cmake/GetGitRevisionDescription.cmake +++ b/cmake/GetGitRevisionDescription.cmake @@ -99,7 +99,7 @@ function(git_describe _var) # (ARGN MATCHES "||") OR # (ARGN MATCHES "\\;")) # message("Please report the following error to the project!") - # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + # message(SYSTEM_ERROR_FATAL "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") #endif() #message(STATUS "Arguments to execute_process: ${ARGN}") diff --git a/cmake/MacroLogFeature.cmake b/cmake/MacroLogFeature.cmake index 631c7ac02..01924ad5e 100644 --- a/cmake/MacroLogFeature.cmake +++ b/cmake/MacroLogFeature.cmake @@ -149,7 +149,7 @@ MACRO(MACRO_DISPLAY_FEATURE_LOG) IF(_haveMissingReq) - MESSAGE(FATAL_ERROR "Exiting: Missing Requirements") + MESSAGE(SYSTEM_ERROR_FATAL "Exiting: Missing Requirements") ENDIF(_haveMissingReq) ENDIF(_printSummary) diff --git a/include/YapError.h b/include/YapError.h index 598c28b5b..08f6360f5 100644 --- a/include/YapError.h +++ b/include/YapError.h @@ -16,196 +16,102 @@ #ifndef YAP_ERROR_H #define YAP_ERROR_H 1 -/* Types of Errors */ -typedef enum -{ - YAP_NO_ERROR, - FATAL_ERROR, - INTERNAL_ERROR, - INTERNAL_COMPILER_ERROR, - NOJIT_ERROR, /* I added */ - PURE_ABORT, - CALL_COUNTER_UNDERFLOW, - /* ISO_ERRORS */ - CONSISTENCY_ERROR, - DOMAIN_ERROR_ARRAY_OVERFLOW, - DOMAIN_ERROR_ARRAY_TYPE, - DOMAIN_ERROR_FILE_ERRORS, - DOMAIN_ERROR_FILE_TYPE, - DOMAIN_ERROR_IO_MODE, - DOMAIN_ERROR_MUTABLE, - DOMAIN_ERROR_NON_EMPTY_LIST, - DOMAIN_ERROR_NOT_LESS_THAN_ZERO, - DOMAIN_ERROR_NOT_NL, - DOMAIN_ERROR_NOT_ZERO, - DOMAIN_ERROR_OUT_OF_RANGE, - DOMAIN_ERROR_OPERATOR_PRIORITY, - DOMAIN_ERROR_OPERATOR_SPECIFIER, - DOMAIN_ERROR_PROLOG_FLAG, - DOMAIN_ERROR_RADIX, - DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, - DOMAIN_ERROR_SOLUTIONS, - DOMAIN_ERROR_SOURCE_SINK, - DOMAIN_ERROR_STREAM, - DOMAIN_ERROR_STREAM_ENCODING, - DOMAIN_ERROR_STREAM_OR_ALIAS, - DOMAIN_ERROR_STREAM_POSITION, - DOMAIN_ERROR_TIMEOUT_SPEC, - DOMAIN_ERROR_SYNTAX_ERROR_HANDLER, - EVALUATION_ERROR_FLOAT_OVERFLOW, - EVALUATION_ERROR_FLOAT_UNDERFLOW, - EVALUATION_ERROR_INT_OVERFLOW, - EVALUATION_ERROR_UNDEFINED, - EVALUATION_ERROR_UNDERFLOW, - EVALUATION_ERROR_ZERO_DIVISOR, - EXISTENCE_ERROR_ARRAY, - EXISTENCE_ERROR_KEY, - EXISTENCE_ERROR_MUTEX, - EXISTENCE_ERROR_SOURCE_SINK, - EXISTENCE_ERROR_STREAM, - EXISTENCE_ERROR_VARIABLE, - INCOMPATIBLEMODE_WARNING, /* I added */ - INCOMPATIBLE_CODEMODE_WARNING, /* I added */ - INSTANTIATION_ERROR, - INTERRUPT_ERROR, - INVALID_PARAMETER_TYPE_ERROR, /* I added */ - OPERATING_SYSTEM_ERROR, - OUT_OF_HEAP_ERROR, - OUT_OF_KNOWNRANGE_ERROR, /* I added */ - OUT_OF_STACK_ERROR, - OUT_OF_TRAIL_ERROR, - OUT_OF_ATTVARS_ERROR, - OUT_OF_AUXSPACE_ERROR, - PERMISSION_ERROR_ACCESS_PRIVATE_PROCEDURE, - PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM, - PERMISSION_ERROR_CREATE_ARRAY, - PERMISSION_ERROR_CREATE_OPERATOR, - PERMISSION_ERROR_INPUT_BINARY_STREAM, - PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, - PERMISSION_ERROR_INPUT_STREAM, - PERMISSION_ERROR_INPUT_TEXT_STREAM, - PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, - PERMISSION_ERROR_OPEN_SOURCE_SINK, - PERMISSION_ERROR_OUTPUT_BINARY_STREAM, - PERMISSION_ERROR_OUTPUT_STREAM, - PERMISSION_ERROR_OUTPUT_TEXT_STREAM, - PERMISSION_ERROR_RESIZE_ARRAY, - PERMISSION_ERROR_READ_ONLY_FLAG, - PERMISSION_ERROR_REPOSITION_STREAM, - PRED_ENTRY_COUNTER_UNDERFLOW, - REPRESENTATION_ERROR_CHARACTER, - REPRESENTATION_ERROR_CHARACTER_CODE, - REPRESENTATION_ERROR_INT, - REPRESENTATION_ERROR_MAX_ARITY, - REPRESENTATION_ERROR_VARIABLE, - RESOURCE_ERROR_HUGE_INT, - RESOURCE_ERROR_MAX_STREAMS, - RESOURCE_ERROR_MAX_THREADS, - RESOURCE_ERROR_MEMORY, - RESOURCE_ERROR_STACK, - RETRY_COUNTER_UNDERFLOW, - SAVED_STATE_ERROR, - SYNTAX_ERROR, - SYSTEM_ERROR, - TYPE_ERROR_ARRAY, - TYPE_ERROR_ATOM, - TYPE_ERROR_ATOMIC, - TYPE_ERROR_BIGNUM, - TYPE_ERROR_BYTE, - TYPE_ERROR_CALLABLE, - TYPE_ERROR_CHAR, - TYPE_ERROR_CHARACTER, - TYPE_ERROR_COMPOUND, - TYPE_ERROR_DBREF, - TYPE_ERROR_DBTERM, - TYPE_ERROR_EVALUABLE, - TYPE_ERROR_FLOAT, - TYPE_ERROR_INTEGER, - TYPE_ERROR_KEY, - TYPE_ERROR_LIST, - TYPE_ERROR_NUMBER, - TYPE_ERROR_PARAMETER, - TYPE_ERROR_PREDICATE_INDICATOR, - TYPE_ERROR_PTR, - TYPE_ERROR_REFERENCE, - TYPE_ERROR_STRING, - TYPE_ERROR_TEXT, - TYPE_ERROR_UBYTE, - TYPE_ERROR_UCHAR, - TYPE_ERROR_VARIABLE, - UNINSTANTIATION_ERROR, - UNKNOWN_ERROR -} yap_error_number; +#define ECLASS(CL, A, B) CL, + +#define E0(A, B) A, +#define E(A, B, C) A, +#define E2(A, B, C, D) A, + +#define BEGIN_ERRORS() typedef enum { + +#define END_ERRORS() \ + } \ + yap_error_number + +#define BEGIN_ERROR_CLASSES() typedef enum { + +#define END_ERROR_CLASSES() \ + } \ + yap_error_class_number + +#include "YapErrors.h" + +struct yami *Yap_Error__(const char *file, const char *function, int lineno, yap_error_number err,YAP_Term wheret, ...); + +#define Yap_Error( id, t, ...) Yap_Error__(__FILE__, __FUNCTION__, __LINE__, id, t, __VA_ARGS__) +#define Yap_NilError( id, ...) Yap_Error__(__FILE__, __FUNCTION__, __LINE__, id, TermNil, __VA_ARGS__) -#define JMP_LOCAL_ERROR(v, LAB) \ - if (H + 2*(v) > ASP-1024) { \ - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;\ - LOCAL_Error_Term = TermNilnnnnnnnnnnnnnnnnnnnnnnnnnn;\ - LOCAL_Error_Size = 2*(v)*sizeof(CELL);\ - goto LAB; \ +#define JMP_LOCAL_ERROR(v, LAB) \ + if (H + 2 * (v) > ASP - 1024) { \ + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; \ + LOCAL_Error_Term = t; \ + LOCAL_Error_Size = 2 * (v) * sizeof(CELL); \ + goto LAB; \ } -#define LOCAL_ERROR(v) \ - if (HR + (v) > ASP-1024) { \ - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;\ - LOCAL_Error_Term = TermNil;\ - LOCAL_Error_Size = 2*(v)*sizeof(CELL);\ - return NULL; \ +#define LOCAL_ERROR(t, v) \ + if (HR + (v) > ASP - 1024) { \ + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; \ + LOCAL_Error_Term = t; \ + LOCAL_Error_Size = 2 * (v) * sizeof(CELL); \ + return NULL; \ } -#define LOCAL_TERM_ERROR(v) \ - if (HR + (v) > ASP-1024) { \ - ;\ - LOCAL_Error_Size = 2*(v)*sizeof(CELL);\ - return 0L; \ +#define LOCAL_TERM_ERROR(t, v) \ + if (HR + (v) > ASP - 1024) { \ + LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; \ + LOCAL_Error_Term = t; \ + LOCAL_Error_Size = 2 * (v) * sizeof(CELL); \ + return 0L; \ } -#define AUX_ERROR(t, n, s, TYPE) \ - if (s + (n+1) > (TYPE *)AuxSp) { \ - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;\ - LOCAL_Error_Term = t;\ - LOCAL_Error_Size = n*sizeof(TYPE);\ - return NULL; \ - } +#define AUX_ERROR(t, n, s, TYPE) \ + if (s + (n + 1) > (TYPE *)AuxSp) { \ + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; \ + LOCAL_Error_Term = t; \ + LOCAL_Error_Size = n * sizeof(TYPE); \ + return NULL; \ + } -#define AUX_TERM_ERROR(t, n, s, TYPE) \ - if (s + (n+1) > (TYPE *)AuxSp) { \ - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;\ - LOCAL_Error_Term = t;\ - LOCAL_Error_Size = n*sizeof(TYPE);\ - return 0L; \ - } +#define AUX_TERM_ERROR(t, n, s, TYPE) \ + if (s + (n + 1) > (TYPE *)AuxSp) { \ + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; \ + LOCAL_Error_Term = t; \ + LOCAL_Error_Size = n * sizeof(TYPE); \ + return 0L; \ + } -#define JMP_AUX_ERROR(n, s, t, TYPE, LAB) \ - if (s + (n+1) > (TYPE *)AuxSp) { \ - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;\ - LOCAL_Error_Term = t;\ - LOCAL_Error_Size = n*sizeof(TYPE);\ - goto LAB; \ - } +#define JMP_AUX_ERROR(n, s, t, TYPE, LAB) \ + if (s + (n + 1) > (TYPE *)AuxSp) { \ + LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; \ + LOCAL_Error_Term = t; \ + LOCAL_Error_Size = n * sizeof(TYPE); \ + goto LAB; \ + } -#define HEAP_ERROR(a,TYPE) if( a == NIL) { \ - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;\ - LOCAL_Error_Term = t;\ - LOCAL_Error_Size = n*sizeof(TYPE);\ - return NULL;\ - } - -#define HEAP_TERM_ERROR(a,TYPE) if( a == NIL) { \ - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;\ - LOCAL_Error_Term = t;\ - LOCAL_Error_Size = n*sizeof(TYPE);\ - return 0L;\ - } - -#define JMP_HEAP_ERROR(a,n,t,TYPE, LAB) if( a == NIL) { \ - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR;\ - LOCAL_Error_Term = t;\ - LOCAL_Error_Size = n*sizeof(TYPE);\ - goto LAB;\ - } +#define HEAP_ERROR(a, TYPE) \ + if (a == NIL) { \ + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; \ + LOCAL_Error_Term = t; \ + LOCAL_Error_Size = n * sizeof(TYPE); \ + return NULL; \ + } +#define HEAP_TERM_ERROR(a, TYPE) \ + if (a == NIL) { \ + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; \ + LOCAL_Error_Term = t; \ + LOCAL_Error_Size = n * sizeof(TYPE); \ + return 0L; \ + } +#define JMP_HEAP_ERROR(a, n, t, TYPE, LAB) \ + if (a == NIL) { \ + LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; \ + LOCAL_Error_Term = t; \ + LOCAL_Error_Size = n * sizeof(TYPE); \ + goto LAB; \ + } #endif diff --git a/include/YapErrors.h b/include/YapErrors.h new file mode 100644 index 000000000..3ec98ad22 --- /dev/null +++ b/include/YapErrors.h @@ -0,0 +1,152 @@ +BEGIN_ERROR_CLASSES() + + ECLASS(NO_ERROR, "no_error", 0) + ECLASS(DOMAIN_ERROR, "domain_error", 2) + ECLASS(EVALUATION_ERROR, "evaluation_error", 2) + ECLASS(EXISTENCE_ERROR, "existence_error", 2) + ECLASS(INSTANTIATION_ERROR_CLASS, "instantiation_error", 0) + ECLASS(PERMISSION_ERROR, "permission_error", 3) + ECLASS(REPRESENTATION_ERROR, "representation_error", 2) + ECLASS(RESOURCE_ERROR, "resource_error", 2) + ECLASS(SYNTAX_ERROR_CLASS, "syntax_error", 2) + ECLASS(SYSTEM_ERROR_CLASS, "system_error", 2) + ECLASS(TYPE_ERROR, "type_error", 2) + ECLASS(UNINSTANTIATION_ERROR_CLASS, "uninstantiation_error", 1) + ECLASS(EVENT, "event", 2) + + END_ERROR_CLASSES(); + +BEGIN_ERRORS() + +/* ISO_ERRORS */ + + E0(YAP_NO_ERROR, NO_ERROR) + + E(DOMAIN_ERROR_ARRAY_OVERFLOW, DOMAIN_ERROR, "array_overflow") + E(DOMAIN_ERROR_ARRAY_TYPE, DOMAIN_ERROR, "array_type") + E(DOMAIN_ERROR_FILE_ERRORS, DOMAIN_ERROR, "file_errors") + E(DOMAIN_ERROR_FILE_TYPE, DOMAIN_ERROR, "file_type") + E(DOMAIN_ERROR_IO_MODE, DOMAIN_ERROR, "io_mode") + E(DOMAIN_ERROR_MUTABLE, DOMAIN_ERROR, "mutable") + E(DOMAIN_ERROR_NON_EMPTY_LIST, DOMAIN_ERROR, "non_empty_list") + E(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, DOMAIN_ERROR, "not_less_than_zero") + E(DOMAIN_ERROR_NOT_NL, DOMAIN_ERROR, "not_nl") + E(DOMAIN_ERROR_NOT_ZERO, DOMAIN_ERROR, "not_zero") + E(DOMAIN_ERROR_OUT_OF_RANGE, DOMAIN_ERROR, "out_of_range") + E(DOMAIN_ERROR_OPERATOR_PRIORITY, DOMAIN_ERROR, "operator_priority") + E(DOMAIN_ERROR_OPERATOR_SPECIFIER, DOMAIN_ERROR, "operator_specifier") + E(DOMAIN_ERROR_RADIX, DOMAIN_ERROR, "radix") + E(DOMAIN_ERROR_PROLOG_FLAG, DOMAIN_ERROR, "prolog_flag") + E(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, DOMAIN_ERROR, "shift_count_overflow") + E(DOMAIN_ERROR_SOURCE_SINK, DOMAIN_ERROR, "source_sink") + E(DOMAIN_ERROR_SOLUTIONS, DOMAIN_ERROR, "solutions") + E(DOMAIN_ERROR_STREAM, DOMAIN_ERROR, "stream") + E(DOMAIN_ERROR_STREAM_ENCODING, DOMAIN_ERROR, "stream_encoding") + E(DOMAIN_ERROR_STREAM_OR_ALIAS, DOMAIN_ERROR, "stream_or_alias") + E(DOMAIN_ERROR_STREAM_POSITION, DOMAIN_ERROR, "stream_position") + E(DOMAIN_ERROR_TIMEOUT_SPEC, DOMAIN_ERROR, "timeout_spec") + E(DOMAIN_ERROR_SYNTAX_ERROR_HANDLER, DOMAIN_ERROR, "syntax_error_handler") + + E(EVALUATION_ERROR_FLOAT_OVERFLOW, EVALUATION_ERROR, "float_overflow") + E(EVALUATION_ERROR_FLOAT_UNDERFLOW, EVALUATION_ERROR, "float_underflow") + E(EVALUATION_ERROR_INT_OVERFLOW, EVALUATION_ERROR, "int_overflow") + E(EVALUATION_ERROR_UNDEFINED, EVALUATION_ERROR, "undefined") + E(EVALUATION_ERROR_UNDERFLOW, EVALUATION_ERROR, "underflow") + E(EVALUATION_ERROR_ZERO_DIVISOR, EVALUATION_ERROR, "zero_divisor") + + E(EXISTENCE_ERROR_ARRAY, EXISTENCE_ERROR, "array") + E(EXISTENCE_ERROR_KEY, EXISTENCE_ERROR, "key, ") + E(EXISTENCE_ERROR_MUTEX, EXISTENCE_ERROR, "mutex, ") + E(EXISTENCE_ERROR_SOURCE_SINK, EXISTENCE_ERROR, "source_sink") + E(EXISTENCE_ERROR_STREAM, EXISTENCE_ERROR, "stream") + E(EXISTENCE_ERROR_VARIABLE, EXISTENCE_ERROR, "variable") + + E0(INSTANTIATION_ERROR, INSTANTIATION_ERROR_CLASS) + + E2(PERMISSION_ERROR_ACCESS_PRIVATE_PROCEDURE, PERMISSION_ERROR, "access","private_procedure") + E2(PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM, PERMISSION_ERROR, + "add_alias", "stream") + E2(PERMISSION_ERROR_CREATE_ARRAY, PERMISSION_ERROR, "create", "array") + E2(PERMISSION_ERROR_CREATE_OPERATOR, PERMISSION_ERROR, "create", "operator") + E2(PERMISSION_ERROR_INPUT_BINARY_STREAM, PERMISSION_ERROR, + "input", "binary_stream") + E2(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, PERMISSION_ERROR, + "input", "past_end_of_stream") + E2(PERMISSION_ERROR_INPUT_STREAM, PERMISSION_ERROR, "input","stream") + E2(PERMISSION_ERROR_INPUT_TEXT_STREAM, PERMISSION_ERROR, + "input","text_stream") + E2(PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, PERMISSION_ERROR, + "modify","static_procedure") + E2(PERMISSION_ERROR_OPEN_SOURCE_SINK, PERMISSION_ERROR, "open","source_sink") + E2(PERMISSION_ERROR_OUTPUT_BINARY_STREAM, PERMISSION_ERROR, + "output","binary_stream") + E2(PERMISSION_ERROR_OUTPUT_STREAM, PERMISSION_ERROR, "output","stream") + E2(PERMISSION_ERROR_OUTPUT_TEXT_STREAM, PERMISSION_ERROR, + "output","text_stream") + E2(PERMISSION_ERROR_READ_ONLY_FLAG, PERMISSION_ERROR, "read_only","flag") + E2(PERMISSION_ERROR_RESIZE_ARRAY, PERMISSION_ERROR, "resize","array") + E2(PERMISSION_ERROR_REPOSITION_STREAM, PERMISSION_ERROR, + "reposition","stream") + + E(REPRESENTATION_ERROR_CHARACTER, REPRESENTATION_ERROR, "character") + E(REPRESENTATION_ERROR_CHARACTER_CODE, REPRESENTATION_ERROR, + "character_code") + E(REPRESENTATION_ERROR_INT, REPRESENTATION_ERROR, "int") + E(REPRESENTATION_ERROR_MAX_ARITY, REPRESENTATION_ERROR, "max_arity") + E(REPRESENTATION_ERROR_VARIABLE, REPRESENTATION_ERROR, "variable") + + E(RESOURCE_ERROR_HUGE_INT, RESOURCE_ERROR, "huge_int") + E(RESOURCE_ERROR_MAX_STREAMS, RESOURCE_ERROR, "max_streams") + E(RESOURCE_ERROR_MAX_THREADS, RESOURCE_ERROR, "max_threads") + E(RESOURCE_ERROR_AUXILIARY_STACK, RESOURCE_ERROR, "auxiliary_stack") + E(RESOURCE_ERROR_ATTRIBUTED_VARIABLES, RESOURCE_ERROR, + "attributed_variables") + E(RESOURCE_ERROR_HEAP, RESOURCE_ERROR, "database_space") + E(RESOURCE_ERROR_TRAIL, RESOURCE_ERROR, "trail_space") + E(RESOURCE_ERROR_STACK, RESOURCE_ERROR, "stack_space") + + E(SYNTAX_ERROR, SYNTAX_ERROR_CLASS, "syntax_error") + + E(SYSTEM_ERROR_INTERNAL, SYSTEM_ERROR_CLASS, "internal") + E(SYSTEM_ERROR_COMPILER, SYSTEM_ERROR_CLASS, "compiler") + E(SYSTEM_ERROR_FATAL, SYSTEM_ERROR_CLASS, "fatal") + E(SYSTEM_ERROR_JIT_NOT_AVAILABLE, SYSTEM_ERROR_CLASS, "jit_not_available") + E(SYSTEM_ERROR_OPERATING_SYSTEM, SYSTEM_ERROR_CLASS, "operating_system_error") + E(SYSTEM_ERROR_SAVED_STATE, SYSTEM_ERROR_CLASS, "saved_state_error") + + E(ABORT_EVENT, EVENT, "abort") + E(CALL_COUNTER_UNDERFLOW_EVENT, EVENT, "call_counter_underflow") + E(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT, EVENT, + "pred_entry_counter_underflow") + E(RETRY_COUNTER_UNDERFLOW_EVENT, EVENT, "retry_counter_underflow") + E(INTERRUPT_EVENT, EVENT, "interrupt") + + E(TYPE_ERROR_ARRAY, TYPE_ERROR, "array") + E(TYPE_ERROR_ATOM, TYPE_ERROR, "atom") + E(TYPE_ERROR_ATOMIC, TYPE_ERROR, "atomic") + E(TYPE_ERROR_BIGNUM, TYPE_ERROR, "bignum") + E(TYPE_ERROR_BYTE, TYPE_ERROR, "byte") + E(TYPE_ERROR_CALLABLE, TYPE_ERROR, "callable") + E(TYPE_ERROR_CHAR, TYPE_ERROR, "char") + E(TYPE_ERROR_CHARACTER, TYPE_ERROR, "character") + E(TYPE_ERROR_COMPOUND, TYPE_ERROR, "compound") + E(TYPE_ERROR_DBREF, TYPE_ERROR, "dbref") + E(TYPE_ERROR_DBTERM, TYPE_ERROR, "dbterm") + E(TYPE_ERROR_EVALUABLE, TYPE_ERROR, "evaluable") + E(TYPE_ERROR_FLOAT, TYPE_ERROR, "float") + E(TYPE_ERROR_INTEGER, TYPE_ERROR, "integer") + E(TYPE_ERROR_KEY, TYPE_ERROR, "key") + E(TYPE_ERROR_LIST, TYPE_ERROR, "list") + E(TYPE_ERROR_NUMBER, TYPE_ERROR, "number") + E(TYPE_ERROR_PARAMETER, TYPE_ERROR, "parameter") + E(TYPE_ERROR_PREDICATE_INDICATOR, TYPE_ERROR, "predicate_indicator") + E(TYPE_ERROR_PTR, TYPE_ERROR, "pointer") + E(TYPE_ERROR_REFERENCE, TYPE_ERROR, "reference") + E(TYPE_ERROR_STRING, TYPE_ERROR, "string") + E(TYPE_ERROR_TEXT, TYPE_ERROR, "text") + E(TYPE_ERROR_UBYTE, TYPE_ERROR, "ubyte") + E(TYPE_ERROR_UCHAR, TYPE_ERROR, "uchar") + + E0(UNINSTANTIATION_ERROR, UNINSTANTIATION_ERROR_CLASS) + + END_ERRORS(); diff --git a/include/dswiatoms.h b/include/dswiatoms.h index 83bc8676e..25e81daa8 100644 --- a/include/dswiatoms.h +++ b/include/dswiatoms.h @@ -617,7 +617,7 @@ #define ATOM_syntax_error ((atom_t)(610*2+1)) #define ATOM_syntax_errors ((atom_t)(611*2+1)) #define ATOM_system ((atom_t)(612*2+1)) -#define ATOM_system_error ((atom_t)(613*2+1)) +#define ATOM_SYSTEM_ERROR_INTERNAL ((atom_t)(613*2+1)) #define ATOM_system_init_file ((atom_t)(614*2+1)) #define ATOM_system_thread_id ((atom_t)(615*2+1)) #define ATOM_system_time ((atom_t)(616*2+1)) diff --git a/library/dialect/swi/fli/swi.c b/library/dialect/swi/fli/swi.c index b96c61d2a..85b2a264b 100755 --- a/library/dialect/swi/fli/swi.c +++ b/library/dialect/swi/fli/swi.c @@ -2424,7 +2424,7 @@ X_API predicate_t PL_predicate(const char *name, int arity, const char *m) Atom at; while (!(at = Yap_LookupAtom((char *)m))) { if (!Yap_growheap(FALSE, 0L, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return NULL; } } @@ -2432,7 +2432,7 @@ X_API predicate_t PL_predicate(const char *name, int arity, const char *m) } while (!(at = Yap_LookupAtom((char *)name))) { if (!Yap_growheap(FALSE, 0L, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return NULL; } } diff --git a/library/dialect/swi/os/pl-error.c b/library/dialect/swi/os/pl-error.c index 11f50d4d1..3f3b4ee45 100755 --- a/library/dialect/swi/os/pl-error.c +++ b/library/dialect/swi/os/pl-error.c @@ -485,7 +485,7 @@ int PL_error(const char *pred, int arity, const char *msg, PL_error_code id, ... PL_ATOM, ATOM_no_memory); break; default: - PL_unify_atom(formal, ATOM_system_error); + PL_unify_atom(formal, ATOM_SYSTEM_ERROR_INTERNAL); break; } diff --git a/library/dialect/swi/os/pl-file.c b/library/dialect/swi/os/pl-file.c index 7d854a534..1b9a70644 100644 --- a/library/dialect/swi/os/pl-file.c +++ b/library/dialect/swi/os/pl-file.c @@ -5842,7 +5842,7 @@ struct PL_local_data *Yap_InitThreadIO(int wid) else return &lds; if (!p) { - Yap_Error(OUT_OF_HEAP_ERROR, 0L, "Creating thread %d\n", wid); + Yap_Error(RESOURCE_ERROR_HEAP, 0L, "Creating thread %d\n", wid); return p; } #if THREADS diff --git a/library/mpi/mpi.c b/library/mpi/mpi.c index 1bb7f5b91..113a81026 100644 --- a/library/mpi/mpi.c +++ b/library/mpi/mpi.c @@ -85,7 +85,7 @@ expand_buffer( int space ) tmp = malloc( bufsize + space ); if( tmp == NULL ) { - Yap_Error(SYSTEM_ERROR, TermNil, "out of memory" ); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "out of memory" ); Yap_exit( EXIT_FAILURE ); } memcpy( tmp, buf, bufsize ); @@ -94,7 +94,7 @@ expand_buffer( int space ) #else /* use realloc */ buf = realloc( buf, bufsize + space ); if( buf == NULL ) { - Yap_Error(SYSTEM_ERROR, TermNil, "out of memory"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "out of memory"); Yap_exit( EXIT_FAILURE ); } #endif @@ -147,7 +147,7 @@ Yap exit(FAILURE), whereas in Yap/LAM mpi_open/3 simply fails. Term t; t = MkIntegerTerm(retv); - Yap_Error( SYSTEM_ERROR, t, "MPI_Init() returned non-zero" ); + Yap_Error( SYSTEM_ERROR_INTERNAL, t, "MPI_Init() returned non-zero" ); return FALSE; } MPI_Comm_size( MPI_COMM_WORLD, &numprocs ); diff --git a/library/system.yap b/library/system.yap index fbe3d3d6b..eb36314c8 100644 --- a/library/system.yap +++ b/library/system.yap @@ -410,7 +410,7 @@ also `absolute_file_name/2` and chdir/1. datime(X) :- datime(X, Error), - handle_system_error(Error, off, datime(X)). + handle_SYSTEM_ERROR_INTERNAL(Error, off, datime(X)). mktime(V, A) :- var(V), !, throw(error(instantiation_error,mktime(V,A))). @@ -418,7 +418,7 @@ mktime(In,Out) :- check_mktime_inp(In, mktime(In,Out)), In = datime(Y,Mo,D,H,Mi,S), mktime(Y, Mo, D, H, Mi, S, Out, Error), - handle_system_error(Error, off, mktime(In,Out)). + handle_SYSTEM_ERROR_INTERNAL(Error, off, mktime(In,Out)). check_mktime_inp(V, Inp) :- var(V), !, throw(error(instantiation_error,Inp)). @@ -470,7 +470,7 @@ delete_file(IFile, Dir, Recurse, Ignore) :- delete_file(Type, File, Dir, Recurse, Ignore). delete_file(N, File, _Dir, _Recurse, Ignore) :- number(N), !, % error. - handle_system_error(N, Ignore, delete_file(File)). + handle_SYSTEM_ERROR_INTERNAL(N, Ignore, delete_file(File)). delete_file(directory, File, Dir, Recurse, Ignore) :- delete_directory(Dir, File, Recurse, Ignore), !. delete_file(_, File, _Dir, _Recurse, Ignore) :- @@ -479,7 +479,7 @@ delete_file(_, File, _Dir, _Recurse, Ignore) :- unlink_file(IFile, Ignore) :- true_file_name(IFile, File), unlink(File, N), - handle_system_error(N, Ignore, delete_file(File)). + handle_SYSTEM_ERROR_INTERNAL(N, Ignore, delete_file(File)). delete_directory(on, File, _Recurse, Ignore) :- rm_directory(File, Ignore). @@ -488,7 +488,7 @@ delete_directory(off, File, Recurse, Ignore) :- rm_directory(File, Ignore) :- rmdir(File, Error), - handle_system_error(Error, Ignore, delete_file(File)). + handle_SYSTEM_ERROR_INTERNAL(Error, Ignore, delete_file(File)). delete_directory(on, File, Ignore) :- directory_files(File, FileList, Ignore), @@ -509,23 +509,23 @@ delete_dirfiles([F|Fs], File, Ignore) :- directory_files(File, FileList, Ignore) :- list_directory(File, FileList, Error), - handle_system_error(Error, Ignore, directory_files(File, FileList)). + handle_SYSTEM_ERROR_INTERNAL(Error, Ignore, directory_files(File, FileList)). -handle_system_error(Error, _Ignore, _G) :- var(Error), !. -handle_system_error(Error, off, G) :- atom(Error), !, - throw(error(system_error(Error),G)). -handle_system_error(Error, off, G) :- +handle_SYSTEM_ERROR_INTERNAL(Error, _Ignore, _G) :- var(Error), !. +handle_SYSTEM_ERROR_INTERNAL(Error, off, G) :- atom(Error), !, + throw(error(SYSTEM_ERROR_INTERNAL(Error),G)). +handle_SYSTEM_ERROR_INTERNAL(Error, off, G) :- error_message(Error, Message), - throw(error(system_error(Message),G)). + throw(error(SYSTEM_ERROR_INTERNAL(Message),G)). -handle_system_error(Error, _Id, _Ignore, _G) :- var(Error), !. -handle_system_error(Error, _SIG, off, G) :- integer(Error), !, +handle_SYSTEM_ERROR_INTERNAL(Error, _Id, _Ignore, _G) :- var(Error), !. +handle_SYSTEM_ERROR_INTERNAL(Error, _SIG, off, G) :- integer(Error), !, error_message(Error, Message), - throw(error(system_error(Message),G)). -handle_system_error(signal, SIG, off, G) :- !, - throw(error(system_error(child_signal(SIG)),G)). -handle_system_error(stopped, SIG, off, G) :- - throw(error(system_error(child_stopped(SIG)),G)). + throw(error(SYSTEM_ERROR_INTERNAL(Message),G)). +handle_SYSTEM_ERROR_INTERNAL(signal, SIG, off, G) :- !, + throw(error(SYSTEM_ERROR_INTERNAL(child_signal(SIG)),G)). +handle_SYSTEM_ERROR_INTERNAL(stopped, SIG, off, G) :- + throw(error(SYSTEM_ERROR_INTERNAL(child_stopped(SIG)),G)). file_property(IFile, type(Type)) :- true_file_name(IFile, File), @@ -546,7 +546,7 @@ file_property(IFile, linkto(LinkName)) :- file_property(File, Type, Size, Date, Permissions, LinkName) :- file_property(File, Type, Size, Date, Permissions, LinkName, Error), - handle_system_error(Error, off, file_property(File)). + handle_SYSTEM_ERROR_INTERNAL(Error, off, file_property(File)). file_exists(File) :- var(File), !, @@ -615,7 +615,7 @@ exec(Command, [StdIn, StdOut, StdErr], PID) :- process_err_stream_for_exec(StdErr, Err, G, L2, L3), ( exec_command(TrueCommand, In, Out, Err, PID, Error) -> true ; true ), close_temp_streams(L3), - handle_system_error(Error, off, G). + handle_SYSTEM_ERROR_INTERNAL(Error, off, G). process_inp_stream_for_exec(Error, _, G, L, L) :- var(Error), !, close_temp_streams(L), @@ -695,9 +695,9 @@ shell :- G = shell, get_shell0(FullCommand), exec_command(FullCommand, 0, 1, 2, PID, Error), - handle_system_error(Error, off, G), + handle_SYSTEM_ERROR_INTERNAL(Error, off, G), wait(PID, _Status, Error, Id), - handle_system_error(Error, Id, off, G). + handle_SYSTEM_ERROR_INTERNAL(Error, Id, off, G). shell(Command) :- G = shell(Command), @@ -705,14 +705,14 @@ shell(Command) :- get_shell(Shell,Opt), do_shell(Shell, Opt, Command, Status, Error), Status = 0, - handle_system_error(Error, off, G). + handle_SYSTEM_ERROR_INTERNAL(Error, off, G). shell(Command, Status) :- G = shell(Command, Status), check_command(Command, G), get_shell(Shell,Opt), do_shell(Shell, Opt, Command, Status, Error), - handle_system_error(Error, off, G). + handle_SYSTEM_ERROR_INTERNAL(Error, off, G). protect_command([], [0'"]). % " protect_command([H|L], [H|NL]) :- @@ -735,7 +735,7 @@ get_shell('/bin/sh','-c'). system :- default_shell(Command), do_system(Command, _Status, Error), - handle_system_error(Error, off, system). + handle_SYSTEM_ERROR_INTERNAL(Error, off, system). default_shell(Shell) :- win, !, getenv('COMSPEC', Shell). @@ -747,13 +747,13 @@ system(Command, Status) :- check_command(Command, G), do_system(Command, Status, Error), Status = 0, - handle_system_error(Error, off, G). + handle_SYSTEM_ERROR_INTERNAL(Error, off, G). wait(PID,STATUS) :- var(PID), !, throw(error(instantiation_error,wait(PID,STATUS))). wait(PID,STATUS) :- integer(PID), !, plwait(PID, STATUS, Error, _Detail), - handle_system_error(Error, off, wait(PID,STATUS)). + handle_SYSTEM_ERROR_INTERNAL(Error, off, wait(PID,STATUS)). wait(PID,STATUS) :- throw(error(type_error(integer,PID),wait(PID,STATUS))). @@ -762,22 +762,22 @@ wait(PID,STATUS) :- % host_name(X) :- host_name(X, Error), - handle_system_error(Error, off, host_name(X)). + handle_SYSTEM_ERROR_INTERNAL(Error, off, host_name(X)). host_id(X) :- host_id(X0, Error), - handle_system_error(Error, off, host_id(X)), + handle_SYSTEM_ERROR_INTERNAL(Error, off, host_id(X)), number_codes(X0, S), atom_codes(X, S). pid(X) :- pid(X, Error), - handle_system_error(Error, off, pid(X)). + handle_SYSTEM_ERROR_INTERNAL(Error, off, pid(X)). kill(X,Y) :- integer(X), integer(Y), !, kill(X, Y, Error), - handle_system_error(Error, off, kill(X,Y)). + handle_SYSTEM_ERROR_INTERNAL(Error, off, kill(X,Y)). kill(X,Y) :- (var(X) ; var(Y)), !, throw(error(instantiation_error,kill(X,Y))). kill(X,Y) :- integer(X), !, @@ -790,19 +790,19 @@ mktemp(X,Y) :- var(X), !, mktemp(X,Y) :- atom(X), !, mktemp(X, Y, Error), - handle_system_error(Error, off, mktemp(X,Y)). + handle_SYSTEM_ERROR_INTERNAL(Error, off, mktemp(X,Y)). mktemp(X,Y) :- throw(error(type_error(atom,X),mktemp(X,Y))). tmpnam(X) :- tmpnam(X, Error), - handle_system_error(Error, off, tmpnam(X)). + handle_SYSTEM_ERROR_INTERNAL(Error, off, tmpnam(X)). %%% Added from Theo, path_seperator is used to replace the c predicate dir_separator which is not OS aware tmpdir(TmpDir):- tmpdir(Dir, Error), - handle_system_error(Error, off, tmpdir(Dir)), + handle_SYSTEM_ERROR_INTERNAL(Error, off, tmpdir(Dir)), path_separator(D), (atom_concat(_, D, Dir) -> TmpDir = Dir diff --git a/misc/ATOMS b/misc/ATOMS index 62db31d75..f30c26581 100644 --- a/misc/ATOMS +++ b/misc/ATOMS @@ -248,7 +248,7 @@ A Offline N "offline" A On N "on" A Online N "online" A Open N "open" -A OperatingSystemError N "operating_system_error" +A OperatingSystemError N "operating_SYSTEM_ERROR_INTERNAL" A OperatingSystemSupport N "operating_system_support" A Operator N "operator" A OperatorPriority N "operator_priority" @@ -361,7 +361,7 @@ A SyntaxError N "syntax_error" A SyntaxErrors N "syntax_errors" A SyntaxErrorHandler N "syntax_error_handler" A System N "system" -A SystemError N "system_error" +A SystemError N "SYSTEM_ERROR_INTERNAL" A SystemLibraryDir N "system_library_directory" A Term N "term" A Terms N "terms" diff --git a/misc/SWIATOMS b/misc/SWIATOMS index 8a3b9e405..2c90799e6 100644 --- a/misc/SWIATOMS +++ b/misc/SWIATOMS @@ -622,7 +622,7 @@ A symbol_char "symbol_char" A syntax_error "syntax_error" A syntax_errors "syntax_errors" A system "system" -A system_error "system_error" +A SYSTEM_ERROR_INTERNAL "SYSTEM_ERROR_INTERNAL" A system_init_file "system_init_file" A system_thread_id "system_thread_id" A system_time "system_time" diff --git a/os/chartypes.c b/os/chartypes.c index 886aaef00..9a22479c8 100644 --- a/os/chartypes.c +++ b/os/chartypes.c @@ -39,37 +39,36 @@ static char SccsId[] = "%W% %G%"; #if HAVE_IO_H /* Windows */ #include -#endif +#endif #if HAVE_SOCKET #include #endif #include #ifndef S_ISDIR -#define S_ISDIR(x) (((x)&_S_IFDIR)==_S_IFDIR) +#define S_ISDIR(x) (((x)&_S_IFDIR) == _S_IFDIR) #endif #endif #include "iopreds.h" #include "eval.h" -static Int p_change_type_of_char( USES_REGS1); -static Int p_type_of_char( USES_REGS1); +static Int p_change_type_of_char(USES_REGS1); +static Int p_type_of_char(USES_REGS1); -Term - Yap_StringToNumberTerm(char *s, encoding_t enc) -{ +Term Yap_StringToNumberTerm(char *s, encoding_t enc) { int sno; Term t; sno = Yap_open_buf_read_stream(s, strlen(s), enc, MEM_BUF_USER); - if (sno < 0) + if (sno < 0) return FALSE; GLOBAL_Stream[sno].encoding = enc; UNLOCK(GLOBAL_Stream[sno].streamlock); - while(*s && isblank(*s++)); - t = Yap_scan_num(GLOBAL_Stream+sno); + while (*s && isblank(*s++)) + ; + t = Yap_scan_num(GLOBAL_Stream + sno); GLOBAL_Stream[sno].status = Free_Stream_f; if (t == TermNil) { - CACHE_REGS + CACHE_REGS int sign = 1; if (s[0] == '+') { s++; @@ -78,47 +77,44 @@ Term s++; sign = -1; } - if(strcmp(s,"inf") == 0) { + if (strcmp(s, "inf") == 0) { if (sign > 0) { - return MkFloatTerm(INFINITY); + return MkFloatTerm(INFINITY); } else { - return MkFloatTerm(-INFINITY); + return MkFloatTerm(-INFINITY); } } - if(strcmp(s,"nan") == 0) { + if (strcmp(s, "nan") == 0) { if (sign > 0) { - return MkFloatTerm(NAN); + return MkFloatTerm(NAN); } else { - return MkFloatTerm(-NAN); + return MkFloatTerm(-NAN); } } } return t; } -const char *encvs[] = { "LANG","LC_ALL","LC_CTYPE", NULL }; +const char *encvs[] = {"LANG", "LC_ALL", "LC_CTYPE", NULL}; // wher we can fins an encoding -typedef struct enc_map { - const char *s; - encoding_t e; - } enc_map_t; +typedef struct enc_map { + const char *s; + encoding_t e; +} enc_map_t; -static enc_map_t ematches[] = -{ { "UTF-8", ENC_ISO_UTF8 }, - { "UTF-16", ENC_UTF16_LE }, // ok, this is a very bad name - { "UCS-2", ENC_UTF16_LE }, // ok, this is probably gone by now - { "ISO-LATIN1", ENC_ISO_LATIN1 }, - { "ISO-8859-1", ENC_ISO_LATIN1 }, - { "Windows-1252", ENC_ISO_LATIN1 }, // almost, but not quite - { "CP-1252", ENC_ISO_LATIN1 }, - { "C", ENC_ISO_ASCII }, - { NULL, ENC_OCTET } - }; +static enc_map_t ematches[] = { + {"UTF-8", ENC_ISO_UTF8}, + {"UTF-16", ENC_UTF16_LE}, // ok, this is a very bad name + {"UCS-2", ENC_UTF16_LE}, // ok, this is probably gone by now + {"ISO-LATIN1", ENC_ISO_LATIN1}, + {"ISO-8859-1", ENC_ISO_LATIN1}, + {"Windows-1252", ENC_ISO_LATIN1}, // almost, but not quite + {"CP-1252", ENC_ISO_LATIN1}, + {"C", ENC_ISO_ASCII}, + {NULL, ENC_OCTET}}; - static encoding_t -DefaultEncoding(void) -{ +static encoding_t DefaultEncoding(void) { CACHE_REGS int i = 0, j; char *enc; @@ -127,9 +123,10 @@ DefaultEncoding(void) if (v) { enc = strrchr(v, '.'); /* that's how it is supposed to be, except in OSX */ - if (!enc) enc = v; + if (!enc) + enc = v; // now that we have one name, try to match it - j= 0; + j = 0; while (ematches[j].s != NULL) { if (!strcmp(ematches[j].s, enc)) { return LOCAL_encoding = ematches[j].e; @@ -137,13 +134,14 @@ DefaultEncoding(void) j++; } } - Yap_Warning("System uses unknown default encoding %s (taken from %s)", enc, v ); + Yap_Warning("System uses unknown default encoding %s (taken from %s)", + enc, v); } else { i++; } } - // by default, return UTF-8 - // except in _WIN32 +// by default, return UTF-8 +// except in _WIN32 #ifdef _WIN32 return ENC_UTF16_BE; #else @@ -151,23 +149,18 @@ DefaultEncoding(void) #endif } -encoding_t -Yap_DefaultEncoding(void) -{ - CACHE_REGS +encoding_t Yap_DefaultEncoding(void) { + CACHE_REGS return LOCAL_encoding; } -void -Yap_SetDefaultEncoding(encoding_t new_encoding) -{ - CACHE_REGS +void Yap_SetDefaultEncoding(encoding_t new_encoding) { + CACHE_REGS LOCAL_encoding = new_encoding; } -encoding_t -Yap_InitialEncoding(void) -{return ENC_ISO_UTF8; +encoding_t Yap_InitialEncoding(void) { + return ENC_ISO_UTF8; char *s = getenv("LANG"); size_t sz; @@ -178,28 +171,22 @@ Yap_InitialEncoding(void) return ENC_ISO_UTF8; sz = strlen(s); if (sz >= 5) { - if (s[sz-5] == 'U' && - s[sz-4] == 'T' && - s[sz-3] == 'F' && - s[sz-2] == '-' && - s[sz-1] == '8') { + if (s[sz - 5] == 'U' && s[sz - 4] == 'T' && s[sz - 3] == 'F' && + s[sz - 2] == '-' && s[sz - 1] == '8') { return ENC_ISO_UTF8; } } return ENC_ISO_UTF8; } -static Int -get_default_encoding( USES_REGS1 ) -{ +static Int get_default_encoding(USES_REGS1) { Term out = MkIntegerTerm(Yap_DefaultEncoding()); return Yap_unify(ARG1, out); } -static Int -p_encoding ( USES_REGS1 ) -{ /* '$encoding'(Stream,N) */ - int sno = Yap_CheckStream (ARG1, Input_Stream_f|Output_Stream_f, "encoding/2"); +static Int p_encoding(USES_REGS1) { /* '$encoding'(Stream,N) */ + int sno = + Yap_CheckStream(ARG1, Input_Stream_f | Output_Stream_f, "encoding/2"); Term t = Deref(ARG2); if (sno < 0) return FALSE; @@ -212,11 +199,7 @@ p_encoding ( USES_REGS1 ) return TRUE; } - - -static Int - toupper2( USES_REGS1 ) -{ +static Int toupper2(USES_REGS1) { Int out = IntegerOfTerm(Deref(ARG1)), uout; if (out < 0) { Yap_Error(REPRESENTATION_ERROR_CHARACTER_CODE, ARG1, "toupper"); @@ -229,9 +212,7 @@ static Int return Yap_unify(ARG2, MkIntegerTerm(uout)); } -static Int -tolower2( USES_REGS1 ) -{ +static Int tolower2(USES_REGS1) { Int out = IntegerOfTerm(Deref(ARG1)), uout; if (out < 0) { Yap_Error(REPRESENTATION_ERROR_CHARACTER_CODE, ARG1, "tolower"); @@ -245,11 +226,10 @@ tolower2( USES_REGS1 ) } static Int -p_change_type_of_char ( USES_REGS1 ) -{ /* change_type_of_char(+char,+type) */ - Term t1 = Deref (ARG1); - Term t2 = Deref (ARG2); - if (!IsVarTerm (t1) && !IsIntegerTerm (t1)) + p_change_type_of_char(USES_REGS1) { /* change_type_of_char(+char,+type) */ + Term t1 = Deref(ARG1); + Term t2 = Deref(ARG2); + if (!IsVarTerm(t1) && !IsIntegerTerm(t1)) return FALSE; if (!IsVarTerm(t2) && !IsIntegerTerm(t2)) return FALSE; @@ -257,21 +237,17 @@ p_change_type_of_char ( USES_REGS1 ) return TRUE; } -static Int -p_type_of_char ( USES_REGS1 ) -{ /* type_of_char(+char,-type) */ +static Int p_type_of_char(USES_REGS1) { /* type_of_char(+char,-type) */ Term t; - Term t1 = Deref (ARG1); - if (!IsVarTerm (t1) && !IsIntegerTerm (t1)) + Term t1 = Deref(ARG1); + if (!IsVarTerm(t1) && !IsIntegerTerm(t1)) return FALSE; - t = MkIntTerm(Yap_chtype[IntegerOfTerm (t1)]); - return Yap_unify(t,ARG2); + t = MkIntTerm(Yap_chtype[IntegerOfTerm(t1)]); + return Yap_unify(t, ARG2); } -int -ISOWGetc (int sno) -{ +int ISOWGetc(int sno) { int ch = GLOBAL_Stream[sno].stream_wgetc(sno); if (ch != EOF && GLOBAL_CharConversionTable != NULL) { @@ -280,30 +256,24 @@ ISOWGetc (int sno) return GLOBAL_CharConversionTable[ch]; } } - return ch; + return ch; } - - -static Int -p_force_char_conversion( USES_REGS1 ) -{ +static Int p_force_char_conversion(USES_REGS1) { int i; /* don't actually enable it until someone tries to add a conversion */ if (GLOBAL_CharConversionTable2 == NULL) - return(TRUE); + return (TRUE); for (i = 0; i < MaxStreams; i++) { if (!(GLOBAL_Stream[i].status & Free_Stream_f)) - GLOBAL_Stream[i].stream_wgetc_for_read = ISOWGetc; + GLOBAL_Stream[i].stream_wgetc_for_read = ISOWGetc; } GLOBAL_CharConversionTable = GLOBAL_CharConversionTable2; - return(TRUE); + return (TRUE); } -static Int -p_disable_char_conversion( USES_REGS1 ) -{ +static Int p_disable_char_conversion(USES_REGS1) { int i; for (i = 0; i < MaxStreams; i++) { @@ -311,40 +281,38 @@ p_disable_char_conversion( USES_REGS1 ) GLOBAL_Stream[i].stream_wgetc_for_read = GLOBAL_Stream[i].stream_wgetc; } GLOBAL_CharConversionTable = NULL; - return(TRUE); + return (TRUE); } -static Int -char_conversion( USES_REGS1 ) -{ +static Int char_conversion(USES_REGS1) { Term t0 = Deref(ARG1), t1 = Deref(ARG2); unsigned char *s0, *s1; if (IsVarTerm(t0)) { Yap_Error(INSTANTIATION_ERROR, t0, "char_conversion/2"); - return (FALSE); + return (FALSE); } if (!IsAtomTerm(t0)) { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t0, "char_conversion/2"); - return (FALSE); + return (FALSE); } s0 = RepAtom(AtomOfTerm(t0))->UStrOfAE; if (s0[1] != '\0') { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t0, "char_conversion/2"); - return (FALSE); + return (FALSE); } if (IsVarTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "char_conversion/2"); - return (FALSE); + return (FALSE); } if (!IsAtomTerm(t1)) { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t1, "char_conversion/2"); - return (FALSE); + return (FALSE); } s1 = RepAtom(AtomOfTerm(t1))->UStrOfAE; if (s1[1] != '\0') { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t1, "char_conversion/2"); - return (FALSE); + return (FALSE); } /* check if we do have a table for converting characters */ if (GLOBAL_CharConversionTable2 == NULL) { @@ -352,83 +320,81 @@ char_conversion( USES_REGS1 ) /* don't create a table if we don't need to */ if (s0[0] == s1[0]) - return(TRUE); - GLOBAL_CharConversionTable2 = Yap_AllocCodeSpace(NUMBER_OF_CHARS*sizeof(char)); + return (TRUE); + GLOBAL_CharConversionTable2 = + Yap_AllocCodeSpace(NUMBER_OF_CHARS * sizeof(char)); while (GLOBAL_CharConversionTable2 == NULL) { - if (!Yap_growheap(FALSE, NUMBER_OF_CHARS*sizeof(char), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); - return(FALSE); + if (!Yap_growheap(FALSE, NUMBER_OF_CHARS * sizeof(char), NULL)) { + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); + return (FALSE); } } if (trueGlobalPrologFlag(CHAR_CONVERSION_FLAG)) { - CACHE_REGS + CACHE_REGS if (p_force_char_conversion(PASS_REGS1) == FALSE) - return(FALSE); + return (FALSE); } - for (i = 0; i < NUMBER_OF_CHARS; i++) + for (i = 0; i < NUMBER_OF_CHARS; i++) GLOBAL_CharConversionTable2[i] = i; } /* just add the new entry */ GLOBAL_CharConversionTable2[(int)s0[0]] = s1[0]; /* done */ - return(TRUE); + return (TRUE); } -static Int -p_current_char_conversion( USES_REGS1 ) -{ +static Int p_current_char_conversion(USES_REGS1) { Term t0, t1; unsigned char *s0, *s1; if (GLOBAL_CharConversionTable == NULL) { - return(FALSE); + return (FALSE); } t0 = Deref(ARG1); if (IsVarTerm(t0)) { Yap_Error(INSTANTIATION_ERROR, t0, "current_char_conversion/2"); - return (FALSE); + return (FALSE); } if (!IsAtomTerm(t0)) { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t0, "current_char_conversion/2"); - return (FALSE); + return (FALSE); } s0 = RepAtom(AtomOfTerm(t0))->UStrOfAE; if (s0[1] != '\0') { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t0, "current_char_conversion/2"); - return (FALSE); + return (FALSE); } t1 = Deref(ARG2); if (IsVarTerm(t1)) { char out[2]; - if (GLOBAL_CharConversionTable[(int)s0[0]] == '\0') return(FALSE); + if (GLOBAL_CharConversionTable[(int)s0[0]] == '\0') + return (FALSE); out[0] = GLOBAL_CharConversionTable[(int)s0[0]]; out[1] = '\0'; - return(Yap_unify(ARG2,MkAtomTerm(Yap_LookupAtom(out)))); + return (Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(out)))); } if (!IsAtomTerm(t1)) { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t1, "current_char_conversion/2"); - return (FALSE); + return (FALSE); } s1 = RepAtom(AtomOfTerm(t1))->UStrOfAE; if (s1[1] != '\0') { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t1, "current_char_conversion/2"); - return (FALSE); + return (FALSE); } else { return (GLOBAL_CharConversionTable[(int)s0[0]] == '\0' && - GLOBAL_CharConversionTable[(int)s0[0]] == s1[0] ); + GLOBAL_CharConversionTable[(int)s0[0]] == s1[0]); } } -static Int -p_all_char_conversions( USES_REGS1 ) -{ +static Int p_all_char_conversions(USES_REGS1) { Term out = TermNil; int i; if (GLOBAL_CharConversionTable == NULL) { - return(FALSE); + return (FALSE); } - for (i = NUMBER_OF_CHARS; i > 0; ) { + for (i = NUMBER_OF_CHARS; i > 0;) { i--; if (GLOBAL_CharConversionTable[i] != '\0') { Term t1, t2; @@ -436,33 +402,36 @@ p_all_char_conversions( USES_REGS1 ) s[1] = '\0'; s[0] = GLOBAL_CharConversionTable[i]; t1 = MkAtomTerm(Yap_LookupAtom(s)); - out = MkPairTerm(t1,out); + out = MkPairTerm(t1, out); s[0] = i; t2 = MkAtomTerm(Yap_LookupAtom(s)); - out = MkPairTerm(t2,out); + out = MkPairTerm(t2, out); } } - return(Yap_unify(ARG1,out)); + return (Yap_unify(ARG1, out)); } - -void -Yap_InitChtypes(void) -{ +void Yap_InitChtypes(void) { DefaultEncoding(); - Yap_InitCPred ("$change_type_of_char", 2, p_change_type_of_char, SafePredFlag|SyncPredFlag|HiddenPredFlag); - Yap_InitCPred ("$type_of_char", 2, p_type_of_char, SafePredFlag|SyncPredFlag|HiddenPredFlag); - Yap_InitCPred ("toupper", 2, toupper2, SafePredFlag); - Yap_InitCPred ("tolower", 2, tolower2, SafePredFlag); - Yap_InitCPred ("char_conversion", 2, char_conversion, SyncPredFlag); + Yap_InitCPred("$change_type_of_char", 2, p_change_type_of_char, + SafePredFlag | SyncPredFlag | HiddenPredFlag); + Yap_InitCPred("$type_of_char", 2, p_type_of_char, + SafePredFlag | SyncPredFlag | HiddenPredFlag); + Yap_InitCPred("toupper", 2, toupper2, SafePredFlag); + Yap_InitCPred("tolower", 2, tolower2, SafePredFlag); + Yap_InitCPred("char_conversion", 2, char_conversion, SyncPredFlag); - Yap_InitCPred ("$get_default_encoding", 1, get_default_encoding, SafePredFlag|HiddenPredFlag); + Yap_InitCPred("$get_default_encoding", 1, get_default_encoding, + SafePredFlag | HiddenPredFlag); - Yap_InitCPred ("$encoding", 2, p_encoding, SafePredFlag|SyncPredFlag), + Yap_InitCPred("$encoding", 2, p_encoding, SafePredFlag | SyncPredFlag), - Yap_InitCPred ("$current_char_conversion", 2, p_current_char_conversion, SyncPredFlag|HiddenPredFlag); - Yap_InitCPred ("$all_char_conversions", 1, p_all_char_conversions, SyncPredFlag|HiddenPredFlag); - Yap_InitCPred ("$force_char_conversion", 0, p_force_char_conversion, SyncPredFlag|HiddenPredFlag); - Yap_InitCPred ("$disable_char_conversion", 0, p_disable_char_conversion, SyncPredFlag|HiddenPredFlag); - - } + Yap_InitCPred("$current_char_conversion", 2, p_current_char_conversion, + SyncPredFlag | HiddenPredFlag); + Yap_InitCPred("$all_char_conversions", 1, p_all_char_conversions, + SyncPredFlag | HiddenPredFlag); + Yap_InitCPred("$force_char_conversion", 0, p_force_char_conversion, + SyncPredFlag | HiddenPredFlag); + Yap_InitCPred("$disable_char_conversion", 0, p_disable_char_conversion, + SyncPredFlag | HiddenPredFlag); +} diff --git a/os/chartypes.yap b/os/chartypes.yap index 29a3ffd41..e2db2caaa 100644 --- a/os/chartypes.yap +++ b/os/chartypes.yap @@ -421,7 +421,7 @@ char_conversion( USES_REGS1 ) CharConversionTable2 = Yap_AllocCodeSpace(NUMBER_OF_CHARS*sizeof(char)); while (CharConversionTable2 == NULL) { if (!Yap_growheap(FALSE, NUMBER_OF_CHARS*sizeof(char), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return(FALSE); } } diff --git a/os/console.c b/os/console.c index cd6f1e92e..839679683 100644 --- a/os/console.c +++ b/os/console.c @@ -167,7 +167,7 @@ ConsoleGetc(int sno) LOCAL_PrologMode &= ~ConsoleGetcMode; LOCAL_newline = TRUE; if (LOCAL_PrologMode & AbortMode) { - Yap_Error(PURE_ABORT, TermNil, ""); + Yap_Error(ABORT_EVENT, TermNil, ""); LOCAL_ErrorMessage = "Abort"; return console_post_process_eof(s); } @@ -190,7 +190,7 @@ prompt1 ( USES_REGS1 ) return (FALSE); LOCAL_AtPrompt = a = AtomOfTerm (t); if (strlen ((char *)RepAtom (a)->StrOfAE) > MAX_PROMPT) { - Yap_Error(SYSTEM_ERROR,t,"prompt %s is too long", RepAtom (a)->StrOfAE); + Yap_Error(SYSTEM_ERROR_INTERNAL,t,"prompt %s is too long", RepAtom (a)->StrOfAE); return(FALSE); } strncpy(LOCAL_Prompt, (char *)RepAtom (a)->StrOfAE, MAX_PROMPT); @@ -209,7 +209,7 @@ prompt ( USES_REGS1 ) return (FALSE); a = AtomOfTerm (t); if (strlen(RepAtom (a)->StrOfAE) > MAX_PROMPT) { - Yap_Error(SYSTEM_ERROR,t,"prompt %s is too long", RepAtom (a)->StrOfAE); + Yap_Error(SYSTEM_ERROR_INTERNAL,t,"prompt %s is too long", RepAtom (a)->StrOfAE); return(FALSE); } strncpy(LOCAL_Prompt, (char *)RepAtom (LOCAL_AtPrompt)->StrOfAE, MAX_PROMPT); diff --git a/os/encoding.h b/os/encoding.h index 1f0325383..1fa1322cc 100644 --- a/os/encoding.h +++ b/os/encoding.h @@ -71,7 +71,7 @@ encoding_t enc_id(char *s) if (!strcmp(s, "utf32_le")) return ENC_ISO_UTF32_LE; if (!strcmp(s, "default")) return Yap_DefaultEncoding(); else { - Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, 0, "bad encoding %s, should be {octet,iso_latin_1,iso_ascii,iso_ansi,iso_utf8,utf16_be,utf16_le,utf32_be,utf32_le}", s); + Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, 0, "bad encoding %s", s); return ENC_OCTET; } } diff --git a/os/files.c b/os/files.c index cdb177964..c30f7cf6e 100644 --- a/os/files.c +++ b/os/files.c @@ -566,7 +566,7 @@ same_file( USES_REGS1 ) { struct stat *b1, *b2; while ((char *)HR+sizeof(struct stat)*2 > (char *)(ASP-1024)) { if (!Yap_gcl(2*sizeof(struct stat), 2, ENV,Yap_gcP() ) ) { - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return FALSE; } } diff --git a/os/format.c b/os/format.c index 31aa66e86..84f8c3be7 100644 --- a/os/format.c +++ b/os/format.c @@ -306,7 +306,7 @@ doformat(volatile Term otail, volatile Term oargs, int sno USES_REGS) *HR++ = oargs; *HR++ = otail; if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR,otail,"format/2"); + Yap_Error(RESOURCE_ERROR_HEAP,otail,"format/2"); return FALSE; } oargs = HR[-2]; @@ -343,7 +343,7 @@ doformat(volatile Term otail, volatile Term oargs, int sno USES_REGS) } else if (IsStringTerm(tail)) { fstr = fptr = StringOfTerm(tail); } else { - Yap_Error(CONSISTENCY_ERROR, tail, "format/2"); + Yap_Error(SYSTEM_ERROR_SAVED_STATE, tail, "format/2"); return FALSE; } if (IsVarTerm(args)) { @@ -870,7 +870,7 @@ doformat(volatile Term otail, volatile Term oargs, int sno USES_REGS) goto do_default_error; do_consistency_error: default: - LOCAL_Error_TYPE = CONSISTENCY_ERROR; + LOCAL_Error_TYPE = SYSTEM_ERROR_SAVED_STATE; do_default_error: if (tnum <= 8) targs = NULL; diff --git a/os/iopreds.c b/os/iopreds.c index e8d87b185..56f0b56e1 100644 --- a/os/iopreds.c +++ b/os/iopreds.c @@ -485,6 +485,48 @@ Yap_DebugErrorPuts(const char *s) Yap_DebugPuts (stderr, s); } +void Yap_DebugWriteIndicator( PredEntry *ap ) +{ + Term tmod = ap->ModuleOfPred; + if (!tmod) tmod = TermProlog; +#if THREADS + Yap_DebugPlWrite(MkIntegerTerm(worker_id)); + Yap_DebugPutc(stderr,' '); +#endif + Yap_DebugPutc(stderr,'>'); + Yap_DebugPutc(stderr,'\t'); + Yap_DebugPlWrite(tmod); + Yap_DebugPutc(stderr,':'); + if (ap->ModuleOfPred == IDB_MODULE) { + Term t = Deref(ARG1); + if (IsAtomTerm(t)) { + Yap_DebugPlWrite(t); + } else if (IsIntegerTerm(t)) { + Yap_DebugPlWrite(t); + } else { + Functor f = FunctorOfTerm(t); + Atom At = NameOfFunctor(f); + Yap_DebugPlWrite(MkAtomTerm(At)); + Yap_DebugPutc(stderr,'/'); + Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); + } + } else { + if (ap->ArityOfPE == 0) { + Atom At = (Atom)ap->FunctorOfPred; + Yap_DebugPlWrite(MkAtomTerm(At)); + } else { + Functor f = ap->FunctorOfPred; + Atom At = NameOfFunctor(f); + Yap_DebugPlWrite(MkAtomTerm(At)); + Yap_DebugPutc(stderr,'/'); + Yap_DebugPlWrite(MkIntegerTerm(ArityOfFunctor(f))); + } + } + + Yap_DebugPutc(stderr,'\n'); +} + + #endif /* static */ @@ -1530,13 +1572,13 @@ binary_file(char *file_name) fname = Yap_AbsoluteFile( fname, LOCAL_FileNameBuf); } else { if (!strncpy(LOCAL_FileNameBuf, fname, YAP_FILENAME_MAX)) - return (PlIOError (SYSTEM_ERROR,file_name,"file name is too long in open/3")); + return (PlIOError (SYSTEM_ERROR_INTERNAL,file_name,"file name is too long in open/3")); } } else if (trueGlobalPrologFlag(OPEN_EXPANDS_FILENAME_FLAG)) { fname = Yap_AbsoluteFile( fname, LOCAL_FileNameBuf); } else { if (!strncpy(LOCAL_FileNameBuf, fname, YAP_FILENAME_MAX)) { - return PlIOError (SYSTEM_ERROR,file_name,"file name is too long in open/3"); + return PlIOError (SYSTEM_ERROR_INTERNAL,file_name,"file name is too long in open/3"); } } // binary type @@ -1575,7 +1617,7 @@ binary_file(char *file_name) if (args[OPEN_BOM].tvalue == TermTrue) { needs_bom = true; if (avoid_bom) { - return (PlIOError (SYSTEM_ERROR,file_name,"BOM not compatible with encoding")); + return (PlIOError (SYSTEM_ERROR_INTERNAL,file_name,"BOM not compatible with encoding")); } } else if (args[OPEN_BOM].tvalue == TermFalse) { @@ -1663,7 +1705,7 @@ open4 ( USES_REGS1 ) StreamDesc *st; int sno = GetFreeStreamD(); if (sno < 0) - return (PlIOError (SYSTEM_ERROR,TermNil, "new stream not available for open_null_stream/1")); + return (PlIOError (SYSTEM_ERROR_INTERNAL,TermNil, "new stream not available for open_null_stream/1")); st = &GLOBAL_Stream[sno]; st->status = Append_Stream_f | Output_Stream_f | Null_Stream_f; #if _WIN32 @@ -1672,7 +1714,7 @@ open4 ( USES_REGS1 ) st->file = fopen("/dev/null","w"); #endif if (st->file == NULL) { - Yap_Error( SYSTEM_ERROR, TermNil, "Could not open NULL stream (/dev/null,NUL)" ); + Yap_Error( SYSTEM_ERROR_INTERNAL, TermNil, "Could not open NULL stream (/dev/null,NUL)" ); return false; } st->linepos = 0; diff --git a/os/mem.c b/os/mem.c index 1634f601f..d10217f22 100644 --- a/os/mem.c +++ b/os/mem.c @@ -135,7 +135,7 @@ MemPutc(int sno, int ch) save_machine_regs(); longjmp(*(jmp_buf *)GLOBAL_Stream[sno].u.mem_string.error_handler,1); } else { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP could not grow heap for writing to string"); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, "YAP could not grow heap for writing to string"); } return -1; } @@ -208,7 +208,7 @@ open_mem_read_stream (USES_REGS1) /* $open_mem_read_stream(+List,-Stream) */ } while ((nbuf = (char *)Yap_AllocAtomSpace((sl+1)*sizeof(char))) == NULL) { if (!Yap_growheap(FALSE, (sl+1)*sizeof(char), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return(FALSE); } } @@ -283,7 +283,7 @@ Yap_OpenBufWriteStream( USES_REGS1 ) while ((nbuf = (char *)Yap_AllocAtomSpace(Yap_page_size*sizeof(char))) == NULL) { if (!Yap_growheap(FALSE, Yap_page_size*sizeof(char), NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return -1; } } @@ -298,7 +298,7 @@ open_mem_write_stream (USES_REGS1) /* $open_mem_write_stream(-Stream) */ sno = Yap_OpenBufWriteStream( PASS_REGS1 ); if (sno == -1) - return (PlIOError (SYSTEM_ERROR,TermNil, "new stream not available for open_mem_read_stream/1")); + return (PlIOError (SYSTEM_ERROR_INTERNAL,TermNil, "new stream not available for open_mem_read_stream/1")); t = Yap_MkStream (sno); return (Yap_unify (ARG1, t)); } @@ -359,7 +359,7 @@ peek_mem_write_stream ( USES_REGS1 ) HR = HI; if (!Yap_gcl((ASP-HI)*sizeof(CELL), 3, ENV, Yap_gcP()) ) { UNLOCK(GLOBAL_Stream[sno].streamlock); - Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage); return(FALSE); } i = GLOBAL_Stream[sno].u.mem_string.pos; diff --git a/os/pipes.c b/os/pipes.c index 36078652e..9b383cc07 100644 --- a/os/pipes.c +++ b/os/pipes.c @@ -70,7 +70,7 @@ ConsolePipePutc (int sno, int ch) { DWORD written; if (WriteFile(s->u.pipe.hdl, &c, sizeof(c), &written, NULL) == FALSE) { - PlIOError (SYSTEM_ERROR,TermNil, "write to pipe returned error"); + PlIOError (SYSTEM_ERROR_INTERNAL,TermNil, "write to pipe returned error"); return EOF; } } @@ -108,7 +108,7 @@ PipePutc (int sno, int ch) { DWORD written; if (WriteFile(s->u.pipe.hdl, &c, sizeof(c), &written, NULL) == FALSE) { - PlIOError (SYSTEM_ERROR,TermNil, "write to pipe returned error"); + PlIOError (SYSTEM_ERROR_INTERNAL,TermNil, "write to pipe returned error"); return EOF; } } @@ -177,7 +177,7 @@ ConsolePipeGetc(int sno) } else if (count > 0) { ch = c; } else { - Yap_Error(SYSTEM_ERROR, TermNil, "read"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "read"); return console_post_process_eof(s); } return console_post_process_read_char(ch, s); @@ -208,9 +208,9 @@ PipeGetc(int sno) ch = c; } else { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, "at pipe getc: %s", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "at pipe getc: %s", strerror(errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, "at pipe getc"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "at pipe getc"); #endif return post_process_eof(s); } @@ -246,14 +246,14 @@ open_pipe_stream (USES_REGS1) satt.bInheritHandle = TRUE; if (!CreatePipe(&ReadPipe, &WritePipe, &satt, 0)) { - return (PlIOError (SYSTEM_ERROR,TermNil, "open_pipe_stream/2 could not create pipe")); + return (PlIOError (SYSTEM_ERROR_INTERNAL,TermNil, "open_pipe_stream/2 could not create pipe")); } #else int filedes[2]; if (pipe(filedes) != 0) { - return (PlIOError (SYSTEM_ERROR,TermNil, "open_pipe_stream/2 could not create pipe")); + return (PlIOError (SYSTEM_ERROR_INTERNAL,TermNil, "open_pipe_stream/2 could not create pipe")); } #endif sno = GetFreeStreamD(); diff --git a/os/readline.c b/os/readline.c index db7405b28..b01b741eb 100644 --- a/os/readline.c +++ b/os/readline.c @@ -262,7 +262,7 @@ getLine( int inp, int out ) Yap_external_signal( 0, YAP_INT_SIGNAL ); LOCAL_PrologMode &= ~ConsoleGetcMode; if (LOCAL_PrologMode & AbortMode) { - Yap_Error(PURE_ABORT, TermNil, ""); + Yap_Error(ABORT_EVENT, TermNil, ""); LOCAL_ErrorMessage = "Abort"; return console_post_process_eof(s); } diff --git a/os/readterm.c b/os/readterm.c index 38c8ea4c5..eb7ead2cd 100644 --- a/os/readterm.c +++ b/os/readterm.c @@ -652,22 +652,22 @@ static parser_state_t scanError(REnv *re, FEnv *fe, int inp_stream) { CACHE_REGS fe->t = 0; // running out of memory - if (LOCAL_Error_TYPE == OUT_OF_TRAIL_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_TRAIL) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growtrail(sizeof(CELL) * K16, FALSE)) { return YAP_PARSING_FINISHED; } - } else if (LOCAL_Error_TYPE == OUT_OF_AUXSPACE_ERROR) { + } else if (LOCAL_Error_TYPE == RESOURCE_ERROR_AUXILIARY_STACK) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { return YAP_PARSING_FINISHED; } - } else if (LOCAL_Error_TYPE == OUT_OF_HEAP_ERROR) { + } else if (LOCAL_Error_TYPE == RESOURCE_ERROR_HEAP) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growheap(FALSE, 0, NULL)) { return YAP_PARSING_FINISHED; } - } else if (LOCAL_Error_TYPE == OUT_OF_STACK_ERROR) { + } else if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_gcl(LOCAL_Error_Size, fe->nargs, ENV, CP)) { return YAP_PARSING_FINISHED; @@ -695,10 +695,10 @@ static parser_state_t scanError(REnv *re, FEnv *fe, int inp_stream) { static parser_state_t parseError(REnv *re, FEnv *fe, int inp_stream) { CACHE_REGS fe->t = 0; - if (LOCAL_Error_TYPE == OUT_OF_TRAIL_ERROR || - LOCAL_Error_TYPE == OUT_OF_AUXSPACE_ERROR || - LOCAL_Error_TYPE == OUT_OF_HEAP_ERROR || - LOCAL_Error_TYPE == OUT_OF_STACK_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_TRAIL || + LOCAL_Error_TYPE == RESOURCE_ERROR_AUXILIARY_STACK || + LOCAL_Error_TYPE == RESOURCE_ERROR_HEAP || + LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) { return YAP_SCANNING_ERROR; } Term ParserErrorStyle = re->sy; @@ -1234,7 +1234,7 @@ term_to_string(USES_REGS1) { s = Yap_TermToString(ARG2, NULL, 0, &length, 0, Quote_illegal_f|Handle_vars_f); if (!s || ! MkStringTerm(s)) { - Yap_Error(RESOURCE_ERROR_MEMORY,t1,"Could not get memory from the operating system"); + Yap_Error(RESOURCE_ERROR_HEAP,t1,"Could not get memory from the operating system"); return false; } return Yap_unify(ARG2, MkStringTerm(s)); @@ -1267,7 +1267,7 @@ term_to_atom(USES_REGS1) { char * s = Yap_TermToString(t1, NULL, 0, &length, 0, Quote_illegal_f|Handle_vars_f); if (!s || !(at = Yap_LookupAtom(s))) { - Yap_Error(RESOURCE_ERROR_MEMORY,t1,"Could not get memory from the operating system"); + Yap_Error(RESOURCE_ERROR_HEAP,t1,"Could not get memory from the operating system"); return false; } return Yap_unify(ARG2, MkAtomTerm(at)); diff --git a/os/readterm.c.cpp b/os/readterm.c.cpp index 10229ab07..a3e5dfed5 100644 --- a/os/readterm.c.cpp +++ b/os/readterm.c.cpp @@ -614,22 +614,22 @@ resetScanner( struct renv *old_renv, int inp_stream, int why, TokEntry *tokstar setBackQuotesFlag( old_renv->bq ); // running out of memory - if (LOCAL_Error_TYPE == OUT_OF_TRAIL_ERROR) { + if (LOCAL_Error_TYPE == RESOURCE_ERROR_TRAIL) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growtrail (sizeof(CELL) * K16, FALSE)) { return false; } - } else if (LOCAL_Error_TYPE == OUT_OF_AUXSPACE_ERROR) { + } else if (LOCAL_Error_TYPE == RESOURCE_ERROR_AUXILIARY_STACK) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { return false; } - } else if (LOCAL_Error_TYPE == OUT_OF_HEAP_ERROR) { + } else if (LOCAL_Error_TYPE == RESOURCE_ERROR_HEAP) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_growheap(FALSE, 0, NULL)) { return false; } - } else if (LOCAL_Error_TYPE == OUT_OF_STACK_ERROR) { + } else if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) { LOCAL_Error_TYPE = YAP_NO_ERROR; if (!Yap_gcl(LOCAL_Error_Size, nargs, ENV, CP)) { return false; diff --git a/os/readutil.c b/os/readutil.c index b01eae3a7..9acc9d2a1 100644 --- a/os/readutil.c +++ b/os/readutil.c @@ -91,7 +91,7 @@ rl_to_codes(Term TEnd, int do_as_binary, int arity USES_REGS) max_inp -= (buf_sz-1); if (max_inp <= 0) { UNLOCK(GLOBAL_Stream[sno].streamlock); - Yap_Error(OUT_OF_STACK_ERROR, ARG1, "read_line_to_codes/%d", arity); + Yap_Error(RESOURCE_ERROR_STACK, ARG1, "read_line_to_codes/%d", arity); return FALSE; } } @@ -134,7 +134,7 @@ read_stream_to_codes(USES_REGS1) ARG4 = AbsPair(HBASE); ARG5 = (CELL)h0; if (!Yap_gcl((ASP-HBASE)*sizeof(CELL), 5, ENV, Yap_gcP())) { - Yap_Error(OUT_OF_STACK_ERROR, ARG1, "read_stream_to_codes/3"); + Yap_Error(RESOURCE_ERROR_STACK, ARG1, "read_stream_to_codes/3"); return FALSE; } /* build a legal term again */ diff --git a/os/sockets.c b/os/sockets.c index eaaa9b555..c88d44851 100644 --- a/os/sockets.c +++ b/os/sockets.c @@ -108,10 +108,10 @@ SocketGetc(int sno) ch = c; } else { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "( socket_getc: %s)", strerror(errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "(socket_getc)"); #endif return post_process_eof(s); @@ -155,7 +155,7 @@ ConsoleSocketGetc(int sno) } else if (count > 0) { ch = c; } else { - Yap_Error(SYSTEM_ERROR, TermNil, "read"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "read"); return console_post_process_eof(s); } return console_post_process_read_char(ch, s); @@ -178,9 +178,9 @@ ConsoleSocketPutc (int sno, int ch) #else if (write(s->u.socket.fd, &c, sizeof(c)) < 0) { #if HAVE_STRERROR - Yap_Error(FATAL_ERROR, TermNil, "no access to console: %s", strerror(errno)); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "no access to console: %s", strerror(errno)); #else - Yap_Error(FATAL_ERROR, TermNil, "no access to console"); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "no access to console"); #endif } #endif @@ -236,7 +236,7 @@ Yap_InitSocketStream(int fd, socket_info flags, socket_domain domain) { sno = GetFreeStreamD(); if (sno < 0) { - PlIOError (SYSTEM_ERROR,TermNil, "new stream not available for socket/4"); + PlIOError (SYSTEM_ERROR_INTERNAL,TermNil, "new stream not available for socket/4"); return(TermNil); } st = &GLOBAL_Stream[sno]; diff --git a/os/streams.c b/os/streams.c index bea6595c1..41958408b 100644 --- a/os/streams.c +++ b/os/streams.c @@ -422,14 +422,14 @@ static bool SetBuffering(int sno, Atom at) { /* '$set_bufferingt'(+Stream,-ErrorMessage) */ if (at == AtomFull) { if (setvbuf(GLOBAL_Stream[sno].file, NULL, _IOFBF, 0) < 0) - return PlIOError(SYSTEM_ERROR, Yap_MkStream(sno), "could not set buffer"); + return PlIOError(SYSTEM_ERROR_INTERNAL, Yap_MkStream(sno), "could not set buffer"); } else if (at == AtomLine) { if (setvbuf(GLOBAL_Stream[sno].file, NULL, _IOLBF, 0) < 0) - return PlIOError(SYSTEM_ERROR, Yap_MkStream(sno), + return PlIOError(SYSTEM_ERROR_INTERNAL, Yap_MkStream(sno), "could not set line buffering"); } else if (at == AtomFalse) { if (setvbuf(GLOBAL_Stream[sno].file, NULL, _IONBF, 0) < 0) - return PlIOError(SYSTEM_ERROR, Yap_MkStream(sno), + return PlIOError(SYSTEM_ERROR_INTERNAL, Yap_MkStream(sno), "could not set disable buffering"); } else { CACHE_REGS @@ -443,7 +443,7 @@ SetBuffering(int sno, Atom at) { /* '$set_bufferingt'(+Stream,-ErrorMessage) */ static bool SetBuffer(int sno, Int sz) { /* '$set_bufferingt'(+Stream,-ErrorMessage) */ if (setvbuf(GLOBAL_Stream[sno].file, NULL, _IOFBF, sz) < 0) { - return PlIOError(SYSTEM_ERROR, Yap_MkStream(sno), "could not set buffer"); + return PlIOError(SYSTEM_ERROR_INTERNAL, Yap_MkStream(sno), "could not set buffer"); } return true; } @@ -1190,7 +1190,7 @@ static Int GLOBAL_Stream[sno].linepos = IntOfTerm(tp); if (fseek(GLOBAL_Stream[sno].file, (long)(char_pos), 0) == -1) { UNLOCK(GLOBAL_Stream[sno].streamlock); - Yap_Error(SYSTEM_ERROR, tp, "fseek failed for set_stream_position/2"); + Yap_Error(SYSTEM_ERROR_INTERNAL, tp, "fseek failed for set_stream_position/2"); return (FALSE); } GLOBAL_Stream[sno].stream_getc = PlGetc; @@ -1213,7 +1213,7 @@ static Int } if (fseek(GLOBAL_Stream[sno].file, 0L, SEEK_END) == -1) { UNLOCK(GLOBAL_Stream[sno].streamlock); - PlIOError(SYSTEM_ERROR, tp, "fseek failed for set_stream_position/2: %s", + PlIOError(SYSTEM_ERROR_INTERNAL, tp, "fseek failed for set_stream_position/2: %s", strerror(errno)); return (FALSE); } @@ -1326,10 +1326,10 @@ static Int p_stream_select(USES_REGS1) { /* do the real work */ if (select(fdmax + 1, &readfds, &writefds, &exceptfds, ptime) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, "stream_select/3 (select: %s)", + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "stream_select/3 (select: %s)", strerror(errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, "stream_select/3 (select)"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "stream_select/3 (select)"); #endif } while (t1 != TermNil) { diff --git a/os/sysbits.c b/os/sysbits.c index d8efa035a..18fbbd0ba 100644 --- a/os/sysbits.c +++ b/os/sysbits.c @@ -156,7 +156,7 @@ Yap_WinError(char *yap_error) NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), msg, 256, NULL); - Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "%s at %s", msg, yap_error); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil, "%s at %s", msg, yap_error); } #endif /* __WINDOWS__ */ @@ -290,7 +290,7 @@ is_directory(const char *FileName) } return S_ISDIR(buf.st_mode); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "stat not available in this configuration"); return false; #endif @@ -310,12 +310,12 @@ has_access(const char *FileName, int mode) if (access( FileName, mode ) == 0) return true; if (errno == EINVAL) { - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "bad flags to access"); } return false; #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "access not available in this configuration"); return false; #endif @@ -383,7 +383,7 @@ yapExpandVars (const char *source, char *result) result = malloc( YAP_FILENAME_MAX+1); if (strlen(source) >= YAP_FILENAME_MAX) { - Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "%s in true_file-name is larger than the buffer size (%d bytes)", source, strlen(source)); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil, "%s in true_file-name is larger than the buffer size (%d bytes)", source, strlen(source)); } /* step 1: eating home information */ if (source[0] == '~') { @@ -412,13 +412,13 @@ yapExpandVars (const char *source, char *result) res++, src++; res[0] = '\0'; if ((user_passwd = getpwnam (result)) == NULL) { - Yap_FileError(OPERATING_SYSTEM_ERROR, MkAtomTerm(Yap_LookupAtom(source)),"User %s does not exist in %s", result, source); + Yap_FileError(SYSTEM_ERROR_OPERATING_SYSTEM, MkAtomTerm(Yap_LookupAtom(source)),"User %s does not exist in %s", result, source); return NULL; } strncpy (result, user_passwd->pw_dir, YAP_FILENAME_MAX); strcat(result, src); #else - Yap_FileError(OPERATING_SYSTEM_ERROR, MkAtomTerm(Yap_LookupAtom(source)),"User %s cannot be found in %s, missing getpwnam", result, source); + Yap_FileError(SYSTEM_ERROR_OPERATING_SYSTEM, MkAtomTerm(Yap_LookupAtom(source)),"User %s cannot be found in %s, missing getpwnam", result, source); return NULL; #endif } @@ -653,7 +653,7 @@ DirName(const char *X) { if (!o) return NULL; if (( err = _splitpath_s(o, drive, YAP_FILENAME_MAX-1, dir, YAP_FILENAME_MAX-1,NULL, 0, NULL, 0) ) != 0) { - Yap_FileError(OPERATING_SYSTEM_ERROR, TermNil, "could not perform _splitpath %s: %s", X, strerror(errno)); + Yap_FileError(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil, "could not perform _splitpath %s: %s", X, strerror(errno)); return NULL; } @@ -690,7 +690,7 @@ static char *myrealpath( const char *path, char *out) s0 = malloc(strlen(s)+1); strcpy(s0, s); if ((rc = myrealpath(dirname((char *)path), out))==NULL) { - Yap_FileError(OPERATING_SYSTEM_ERROR, TermNil, "could not find file %s: %s", path, strerror(errno)); + Yap_FileError(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil, "could not find file %s: %s", path, strerror(errno)); return NULL; } if(rc[strlen(rc)-1] != '/' ) @@ -943,7 +943,7 @@ initSysPath(Term tlib, Term tcommons, bool dir_done, bool commons_done) { while (*--pt != '\\') { /* skip executable */ if (pt == LOCAL_FileNameBuf) { - Yap_FileError(OPERATING_SYSTEM_ERROR, TermNil, "could not find executable name"); + Yap_FileError(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil, "could not find executable name"); /* do nothing */ return FALSE; } @@ -951,7 +951,7 @@ initSysPath(Term tlib, Term tcommons, bool dir_done, bool commons_done) { while (*--pt != '\\') { /* skip parent directory "bin\\" */ if (pt == LOCAL_FileNameBuf) { - Yap_FileError(OPERATING_SYSTEM_ERROR, TermNil, "could not find executable name"); + Yap_FileError(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil, "could not find executable name"); /* do nothing */ return FALSE; } @@ -1792,7 +1792,7 @@ Yap_random (void) #elif HAVE_RAND return (((double) (rand ()) / RAND_MAX)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "random not available in this configuration"); return (0.0); #endif @@ -2058,17 +2058,17 @@ SearchForTrailFault(void *ptr, int sure) if ((ptr > (void *)LOCAL_TrailTop-1024 && TR < (tr_fr_ptr) LOCAL_TrailTop+(64*1024))) { if (!Yap_growtrail(64*1024, TRUE)) { - Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "YAP failed to reserve %ld bytes in growtrail", K64); + Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, "YAP failed to reserve %ld bytes in growtrail", K64); } /* just in case, make sure the OS keeps the signal handler. */ /* my_signal_info(SIGSEGV, HandleSIGSEGV); */ } else #endif /* OS_HANDLES_TR_OVERFLOW */ if (sure) - Yap_Error(FATAL_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "tried to access illegal address %p!!!!", ptr); else - Yap_Error(FATAL_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "likely bug in YAP, segmentation violation"); } @@ -2083,7 +2083,7 @@ HandleSIGSEGV(int sig, void *sipv, void *uap) void *ptr = TR; int sure = FALSE; if (LOCAL_PrologMode & ExtendStackMode) { - Yap_Error(FATAL_ERROR, TermNil, "OS memory allocation crashed at address %p, bailing out\n",LOCAL_TrailTop); + Yap_Error(SYSTEM_ERROR_FATAL, TermNil, "OS memory allocation crashed at address %p, bailing out\n",LOCAL_TrailTop); } #if (defined(__svr4__) || defined(__SVR4)) siginfo_t *sip = sipv; @@ -2275,7 +2275,7 @@ ReceiveSignal (int s, void *x, void *y) case SIGQUIT: case SIGKILL: LOCAL_PrologMode &= ~InterruptMode; - Yap_Error(INTERRUPT_ERROR,MkIntTerm(s),NULL); + Yap_Error(INTERRUPT_EVENT,MkIntTerm(s),NULL); break; #endif #ifdef SIGUSR1 @@ -2681,9 +2681,9 @@ MSCHandleSignal(DWORD dwCtrlType) { shell = "/bin/sh"; if (system (shell) < 0) { #if HAVE_STRERROR - Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "%s in sh/0", strerror(errno)); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil, "%s in sh/0", strerror(errno)); #else - Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "in sh/0"); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil, "in sh/0"); #endif return FALSE; } @@ -2695,7 +2695,7 @@ MSCHandleSignal(DWORD dwCtrlType) { system (shell); return (TRUE); #else - Yap_Error(SYSTEM_ERROR,TermNil,"sh not available in this configuration"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"sh not available in this configuration"); return(FALSE); #endif /* MSH */ #endif @@ -2772,7 +2772,7 @@ MSCHandleSignal(DWORD dwCtrlType) { system (shell); return TRUE; #else - Yap_Error (SYSTEM_ERROR,TermNil,"shell not available in this configuration"); + Yap_Error (SYSTEM_ERROR_INTERNAL,TermNil,"shell not available in this configuration"); return FALSE; #endif #endif /* HAVE_SYSTEM */ @@ -2811,7 +2811,7 @@ MSCHandleSignal(DWORD dwCtrlType) { &pi ) // Pointer to PROCESS_INFORMATION structure ) { - Yap_Error( SYSTEM_ERROR, ARG1, "CreateProcess failed (%d).\n", GetLastError() ); + Yap_Error( SYSTEM_ERROR_INTERNAL, ARG1, "CreateProcess failed (%d).\n", GetLastError() ); return FALSE; } // Wait until child process exits. @@ -2849,9 +2849,9 @@ MSCHandleSignal(DWORD dwCtrlType) { #endif if (system (s)) { #if HAVE_STRERROR - Yap_Error(OPERATING_SYSTEM_ERROR,t1,"%s in system(%s)", strerror(errno), s); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM,t1,"%s in system(%s)", strerror(errno), s); #else - Yap_Error(OPERATING_SYSTEM_ERROR,t1,"in system(%s)", s); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM,t1,"in system(%s)", s); #endif return FALSE; } @@ -2865,7 +2865,7 @@ MSCHandleSignal(DWORD dwCtrlType) { return (TRUE); #undef command #else - Yap_Error(SYSTEM_ERROR,TermNil,"sh not available in this machine"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"sh not available in this machine"); return(FALSE); #endif #endif /* HAVE_SYSTEM */ @@ -2904,15 +2904,15 @@ MSCHandleSignal(DWORD dwCtrlType) { unlink (newname); if (r != 0) { #if HAVE_STRERROR - Yap_Error(OPERATING_SYSTEM_ERROR,t2,"%s in rename(%s,%s)", strerror(errno),oldname,newname); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM,t2,"%s in rename(%s,%s)", strerror(errno),oldname,newname); #else - Yap_Error(OPERATING_SYSTEM_ERROR,t2,"in rename(%s,%s)",oldname,newname); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM,t2,"in rename(%s,%s)",oldname,newname); #endif return FALSE; } return TRUE; #else - Yap_Error(SYSTEM_ERROR,TermNil,"rename/2 not available in this machine"); + Yap_Error(SYSTEM_ERROR_INTERNAL,TermNil,"rename/2 not available in this machine"); return (FALSE); #endif } @@ -2968,7 +2968,7 @@ MSCHandleSignal(DWORD dwCtrlType) { to = MkAtomTerm(Yap_LookupAtom(so)); return(Yap_unify_constant(ARG2,to)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "getenv not available in this configuration"); return (FALSE); #endif @@ -3001,7 +3001,7 @@ MSCHandleSignal(DWORD dwCtrlType) { } else s2 = RepAtom(AtomOfTerm(t2))->StrOfAE; while (!(p0 = p = Yap_AllocAtomSpace(strlen(s)+strlen(s2)+3))) { if (!Yap_growheap(FALSE, MinHeapGap, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage); + Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage); return FALSE; } } @@ -3011,15 +3011,15 @@ MSCHandleSignal(DWORD dwCtrlType) { if (putenv(p0) == 0) return TRUE; #if HAVE_STRERROR - Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil, "in putenv(%s)", strerror(errno), p0); #else - Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, TermNil, "in putenv(%s)", p0); #endif return FALSE; #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "putenv not available in this configuration"); return FALSE; #endif @@ -3126,9 +3126,9 @@ MSCHandleSignal(DWORD dwCtrlType) { new.it_value.tv_usec = i2; if (setitimer(ITIMER_REAL, &new, &old) < 0) { #if HAVE_STRERROR - Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "setitimer: %s", strerror(errno)); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "setitimer: %s", strerror(errno)); #else - Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "setitimer %d", errno); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "setitimer %d", errno); #endif return FALSE; } @@ -3148,7 +3148,7 @@ MSCHandleSignal(DWORD dwCtrlType) { /* not actually trying to set the alarm */ if (IntegerOfTerm(t) == 0) return TRUE; - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "alarm not available in this configuration"); return FALSE; #endif @@ -3213,9 +3213,9 @@ MSCHandleSignal(DWORD dwCtrlType) { new.it_value.tv_usec = IntegerOfTerm(t2); if (setitimer(ITIMER_VIRTUAL, &new, &old) < 0) { #if HAVE_STRERROR - Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "setitimer: %s", strerror(errno)); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "setitimer: %s", strerror(errno)); #else - Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "setitimer %d", errno); + Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, "setitimer %d", errno); #endif return FALSE; } @@ -3226,7 +3226,7 @@ MSCHandleSignal(DWORD dwCtrlType) { /* not actually trying to set the alarm */ if (IntegerOfTerm(t) == 0) return TRUE; - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "virtual_alarm not available in this configuration"); return FALSE; #endif @@ -3588,7 +3588,7 @@ MSCHandleSignal(DWORD dwCtrlType) { k = (wchar_t *)Yap_AllocCodeSpace(sz); while (k == NULL) { if (!Yap_growheap(FALSE, sz, NULL)) { - Yap_Error(OUT_OF_HEAP_ERROR, MkIntegerTerm(sz), "generating key in win_registry_get_value/3"); + Yap_Error(RESOURCE_ERROR_HEAP, MkIntegerTerm(sz), "generating key in win_registry_get_value/3"); return FALSE; } } diff --git a/os/ypsocks.c b/os/ypsocks.c index a91862a77..fdf2a820e 100755 --- a/os/ypsocks.c +++ b/os/ypsocks.c @@ -195,9 +195,9 @@ Yap_init_socks(char *host, long interface_port) he = gethostbyname(host); if (he == NULL) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, "can not get address for host %s: %s", host, strerror(h_errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "can not get address for host %s: %s", host, strerror(h_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, "can not get address for host"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "can not get address for host"); #endif return; } @@ -217,9 +217,9 @@ Yap_init_socks(char *host, long interface_port) s = socket ( AF_INET, SOCK_STREAM, 0); if (s<0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, "could not create socket: %s", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "could not create socket: %s", strerror(errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, "could not create socket"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "could not create socket"); #endif return; } @@ -231,10 +231,10 @@ Yap_init_socks(char *host, long interface_port) if (setsockopt(s, SOL_SOCKET, SO_LINGER, (void *) &ling, sizeof(ling)) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (setsockopt_linger: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (setsockopt_linger)"); #endif return; @@ -244,9 +244,9 @@ Yap_init_socks(char *host, long interface_port) r = connect ( s, (struct sockaddr *) &soadr, sizeof(soadr)); if (r<0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, "connect failed, could not connect to interface: %s", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "connect failed, could not connect to interface: %s", strerror(errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, "connect failed, could not connect to interface"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "connect failed, could not connect to interface"); #endif return; } @@ -254,25 +254,25 @@ Yap_init_socks(char *host, long interface_port) #if HAVE_DUP2 && !defined(__MINGW32__) if(dup2(s,0)<0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, "could not dup2 stdin: %s", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "could not dup2 stdin: %s", strerror(errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, "could not dup2 stdin"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "could not dup2 stdin"); #endif return; } if(dup2(s,1)<0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, "could not dup2 stdout: %s", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "could not dup2 stdout: %s", strerror(errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, "could not dup2 stdout"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "could not dup2 stdout"); #endif return; } if(dup2(s,2)<0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, "could not dup2 stderr: %s", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "could not dup2 stderr: %s", strerror(errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, "could not dup2 stderr"); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "could not dup2 stderr"); #endif return; } @@ -316,7 +316,7 @@ Yap_init_socks(char *host, long interface_port) close(s); #endif #else /* HAVE_SOCKET */ - Yap_Error(SYSTEM_ERROR, TermNil, "sockets not installed", strerror(errno)); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "sockets not installed", strerror(errno)); #endif /* HAVE_SOCKET */ } @@ -453,10 +453,10 @@ p_socket(USES_REGS1) fd = socket(domain, type, protocol); if (invalid_socket_fd(fd)) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket/4 (socket: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket/4 (socket)"); #endif return(FALSE); @@ -489,7 +489,7 @@ Yap_CloseSocket(int fd, socket_info status, socket_domain domain) char bfr; if (shutdown(fd, 1) != 0) { - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_close/1 (close)"); return(FALSE); } @@ -499,7 +499,7 @@ Yap_CloseSocket(int fd, socket_info status, socket_domain domain) /* prevent further reading from the socket */ if (shutdown(fd, 0) < 0) { - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_close/1 (close)"); return(FALSE); } @@ -507,10 +507,10 @@ Yap_CloseSocket(int fd, socket_info status, socket_domain domain) /* close the socket */ if (closesocket(fd) != 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_close/1 (close: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_close/1 (close)"); #endif } @@ -519,10 +519,10 @@ Yap_CloseSocket(int fd, socket_info status, socket_domain domain) status == client_socket) { if (shutdown(fd,2) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_close/1 (shutdown: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_close/1 (shutdown)"); #endif return(FALSE); @@ -530,10 +530,10 @@ Yap_CloseSocket(int fd, socket_info status, socket_domain domain) } if (close(fd) != 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_close/1 (close: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_close/1 (close)"); #endif #endif @@ -611,10 +611,10 @@ p_socket_bind(USES_REGS1) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + len)) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_bind/2 (bind: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_bind/2 (bind)"); #endif return(FALSE); @@ -641,10 +641,10 @@ p_socket_bind(USES_REGS1) shost = RepAtom(AtomOfTerm(thost))->StrOfAE; if((he=gethostbyname(shost))==NULL) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_bind/2 (gethostbyname: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_bind/2 (gethostbyname)"); #endif return(FALSE); @@ -660,10 +660,10 @@ p_socket_bind(USES_REGS1) saddr.sin_family = AF_INET; if(bind(fd,(struct sockaddr *)&saddr, sizeof(saddr))==-1) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_bind/2 (bind: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_bind/2 (bind)"); #endif return(FALSE); @@ -679,10 +679,10 @@ p_socket_bind(USES_REGS1) Term t; if (getsockname(fd, (struct sockaddr *)&saddr, &namelen) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_bind/2 (getsockname: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_bind/2 (getsockname)"); #endif return(FALSE); @@ -754,10 +754,10 @@ p_socket_connect(USES_REGS1) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + len))) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (connect: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (connect)"); #endif return(FALSE); @@ -784,10 +784,10 @@ p_socket_connect(USES_REGS1) shost = RepAtom(AtomOfTerm(thost))->StrOfAE; if((he=gethostbyname(shost))==NULL) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (gethostbyname: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (gethostbyname)"); #endif return(FALSE); @@ -814,10 +814,10 @@ p_socket_connect(USES_REGS1) if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (void *) &ling, sizeof(ling)) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (setsockopt_linger: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (setsockopt_linger)"); #endif return FALSE; @@ -830,10 +830,10 @@ p_socket_connect(USES_REGS1) if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (void *)&one, sizeof(one))) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (setsockopt_broadcast: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (setsockopt_broadcast)"); #endif return FALSE; @@ -843,10 +843,10 @@ p_socket_connect(USES_REGS1) flag = connect(fd,(struct sockaddr *)&saddr, sizeof(saddr)); if(flag<0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (connect: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_connect/3 (connect)"); #endif return FALSE; @@ -892,10 +892,10 @@ p_socket_listen(USES_REGS1) } if (listen(fd,j) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_listen/2 (listen: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_listen/2 (listen)"); #endif } @@ -930,10 +930,10 @@ p_socket_accept(USES_REGS1) memset((void *)&caddr,(int) 0, sizeof(caddr)); if ((fd=accept(ofd, (struct sockaddr *)&caddr, &len)) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_accept/3 (accept: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_accept/3 (accept)"); #endif } @@ -955,20 +955,20 @@ p_socket_accept(USES_REGS1) memset((void *)&caddr,(int) 0, sizeof(caddr)); if (invalid_socket_fd(fd=accept(ofd, (struct sockaddr *)&caddr, &len))) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_accept/3 (accept: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_accept/3 (accept)"); #endif return(FALSE); } if ((s = inet_ntoa(caddr.sin_addr)) == NULL) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_accept/3 (inet_ntoa: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_accept/3 (inet_ntoa)"); #endif } @@ -1148,10 +1148,10 @@ p_socket_select(USES_REGS1) /* do the real work */ if (select(fdmax+1, &readfds, &writefds, &exceptfds, ptime) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_select/5 (select: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "socket_select/5 (select)"); #endif } @@ -1173,10 +1173,10 @@ p_current_host(USES_REGS1) { name = oname; if (gethostname(name, sizeof(oname)) < 0) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "current_host/2 (gethostname: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "current_host/2 (gethostname)"); #endif return(FALSE); @@ -1187,10 +1187,10 @@ p_current_host(USES_REGS1) { /* not a fully qualified name, ask the name server */ if((he=gethostbyname(name))==NULL) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "current_host/2 (gethostbyname: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "current_host/2 (gethostbyname)"); #endif return(FALSE); @@ -1210,7 +1210,7 @@ p_current_host(USES_REGS1) { else { int isize = strlen(sin); if (isize >= 256) { - Yap_Error(SYSTEM_ERROR, ARG1, + Yap_Error(SYSTEM_ERROR_INTERNAL, ARG1, "current_host/2 (input longer than longest FAQ host name)"); return(FALSE); } @@ -1252,10 +1252,10 @@ p_hostname_address(USES_REGS1) { if (IsVarTerm(t1)) { if ((he = gethostbyaddr(s, strlen(s), AF_INET)) == NULL) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "hostname_address/2 (gethostbyname: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "hostname_address/2 (gethostbyname)"); #endif } @@ -1265,10 +1265,10 @@ p_hostname_address(USES_REGS1) { struct in_addr adr; if ((he = gethostbyname(s)) == NULL) { #if HAVE_STRERROR - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "hostname_address/2 (gethostbyname: %s)", strerror(socket_errno)); #else - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "hostname_address/2 (gethostbyname)"); #endif } diff --git a/packages/ProbLog/problog/completion.yap b/packages/ProbLog/problog/completion.yap index 7d92187a2..168bdac03 100644 --- a/packages/ProbLog/problog/completion.yap +++ b/packages/ProbLog/problog/completion.yap @@ -243,7 +243,7 @@ reset_completion :- propagate_evidence(_,_) :- \+ current_predicate(user:known/3), !, - throw(error(system_error,'The predicate user:known/3 is not defined. If you really have empty interpretations declare the user:known/3 as dynamic and come back.')). + throw(error(SYSTEM_ERROR_INTERNAL,'The predicate user:known/3 is not defined. If you really have empty interpretations declare the user:known/3 as dynamic and come back.')). propagate_evidence(InterpretationID,Query_Type) :- diff --git a/packages/bdd/cmake/FindYAP.cmake b/packages/bdd/cmake/FindYAP.cmake index 3ca553a01..220206c94 100644 --- a/packages/bdd/cmake/FindYAP.cmake +++ b/packages/bdd/cmake/FindYAP.cmake @@ -67,7 +67,7 @@ IF (YAP_FOUND) ELSE (YAP_FOUND) IF (YAP_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find YAP") + MESSAGE(SYSTEM_ERROR_FATAL "Could not find YAP") ENDIF (YAP_FIND_REQUIRED) ENDIF (YAP_FOUND) diff --git a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/QCubed.png b/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/QCubed.png deleted file mode 100644 index bcb63dd772f337ffbdd513fcbe0d4216bb41da14..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8380 zcmV;tAVc4YP)koIgzCO4SNK}kOLS8Ml?;gK=eniL^e4)dwqIw;op#oRTg7Fj5qYFK+uJSJ^6gR1i=>5{V2{P|Z#l>6w&AbW-JiJ8(mQpqeBSnW{oVKurS( zK*$(auN;F=O3CoESS6mWH3TTCNg|O!6%4^UssZ*5g_tCV2x!?uCQJV}ECZfJH?9%W z(WB|8B7)&aBx2^WpbE`%Xe0A5dZv7WxH{raDnqUpw}-x6G**G;9VjYIB6ZXbnCAmy zNRu4?d@3bF&cSOU0uX~?Tp5EZW+#UnZYP}puw-5|7tLd4V~AgiOqkEj74tW`+%)g^ zd2KcGm(N{CdCvLs=FA)g{PQ1~PY}87^VQ@CPBp>&ZhkOdm|w6zPMOR8zGuw(2>M9F z-{Vt6Zu!3H9(2#U=BD}9d~N>305T2UQR`X!ntL_DLV|1_w%@<&6NF{>N^}SZ4 z{GhlM4VK~uv#trQYvkhA#x=$$<&yod%kEmSuzb{#4=!LyjD@I4v@BWOSSX4JTtGnH zT<*Pi;qtimoHJ*7|GzWyuWq_~PM?#*DeO~SJ=4?EJ*T^W{eSihf%IG1Ya^y%cc<^9mWpJHYVm-BvGntIovuBU^;DZnTs*gOZUVi!IMRVrNxoPUusmt!V z>n^c>|9-&%Wf9(a=N++q`}UhlrPBA_efQmU$mfVU&GXAIzkFo znOM7a?NujEoETWKV#TYs-+ucKsjrsadh4y|ca*p9SE=_}7>1(1zh88Ac8VQ4c0AnO z-Hm6S@!*3Gt}T-&iik2CauQ0Uq5^70AaR>%dO!Mev1`?;zoD}=I>@94jhPyG--s_c z#MZ!(9$CNsR~P(b?n8sdoM};81}{g&F*F^d4~`f)@;5VYx=BnXkkUX`z}DT6ji7!-qidXhJ>t*uS84j(SI(KP`;CBP18aEmm!xqKdNO`yDW$gdVDv|w^y zG`xv(Fa8T3f}Ity^PIQ}lB}fm1J`1LS;i zVI9)aA~tT=u;iR`&iNi?|AGK}+yo~F0_hX95I!}3{(LNk0G8OZZ=dL=K1Vq`7n>f1 z0T#|f>MFC3zzERe|0dwQ_>42oz*wN)85>;Qo9gxB*?1mgb2;%XTF{3L8z%Pc+xN+{ z&p!K$2OfA}p*9CtMkVxyB_T>#G^{kgjt~|KvP^g#`@eraB)$QmXXcH^ON9ZEEfs+f zCxwnEAAm21p@^Cf(nXhDc3C@C-D0sQ*3qi`)mLAM#whsSbl^Q6NqP z)cWDWhY#nm@R?K?Ae=aH;@@6!$t6!MTC@lhNi12iMC{tNO95Gd$aU_`3pii>?*UN2 z{j?D508pLv)_=}`1;=&%`R5B-nEqw);>F|W($DX^@4gdUJ{OiF5f)460i~$H%?{#N z0ksfWP>F9qz_Vn)(v}_6QfkVj2tXy^M9l^1zukD_jqS5$%@Ut{@=1kt0=sGe#JtA` z+SEK^t*!fw-~*{yA3y>iq_(SH%jI&8_8Sk(?oF650igSPN)HmHS)iA>;DQUr5WD`; zlTSX$AO*{=v(x%>S?35fIJQt z&vIn#lv%}U_0{rRx~$uPY06L4#*G^XIqoR}>+cAx8?;NaX;BmeR`LAv&x2#JpVO8* zU3q?Rsj|9kUk^CzE<1eqa4cB!UV7=JoiD!l;(sL+6+&xCh+@(>E0m;7Q6mVs-yoo7 zr4V5$6xm|Il8$tciUiQ*=799lGtWG8(QUWg#*`G4K%c~oP*eThL8%ne4n8WXAN#m$Kl8F-P*mvMSA?oauX1i@t#y~9=T|J`J0gZK2 zSl=I9bkRkkxA!nqaMwoRrn;0~IPkF#^C&f^<@aiORx+M2qho1jL_CojOhQ^mJPurMX-{ zF$VyQqBi+nECgr+&!Ekjcn%kfC6u2>8E<*|+1Ky;SFKug1R!LPalc!8p=BAIL@ob2 zN9Cr_|6T!ZVf5%WrqC7|a=ARf3`N;Yu)Z2al?+sqCt!+dDw7zPU_YfS76>1#$g!y@ z@}xdVOos}C?d3aBcMzEEGD{nZT&ZZ-ebsfzTHmlK%A{$qt#x)Dpg}57hg)(Rs4PH= z!+8rAE-YhEKp~K7$KG=zP(H4?Sl{|6D+3J2*(_qlQP#=&y2>JtpEpC)U`sWsFQx1t zg-{2vcR&5kcfKvwtXTu)kzu~zHiWd>&r;OcP*(cHGCes@Y-O7z(!Veo|2sg`dkFRG zV;?>D+;iLX`vG+0c++E#JvO?xw|4=7^`X|*;lLEbj8iNK4AdXQ$|R6$YuAi}2Zwi0 zU{h3?m~J8fMoKlXyvoL@Jz%Ch$`N-;1!5^>5IHD$85Fe~ic+C)GW%n(!A-NHj>KwD z6D`eQfz1YYKK=C5BZ5~(^^dD{O!MLJM9qCl|`i7+goz6zCl!u4sYB5S1|^t z?LwFUwH%)}Coo`)L5;$Y6%t+PH~T?p1*T|ldQb(e@$yp$Tkh2RGT>{}jv0`Ls5Qp< z9*S&%btn`@@J9N0?ONQg#3O(dI*7Or58*zueQr`esM=~tSl>`&kPluv)iX&}CY?-^6(Q@E3Na`%Iz^3RWXh|__PR1D9?B>B z36ujOL>ws4MYI($8w^TacG+(uDFXm7qk%LqeS9(4cs8`x1dIYOXdkIHDK%c`Raz&Et{J z0bnJfsM)9tplXzqQbUOf4RPcGOr?0NfyGgl*+9PA!_*^a0GK|HBfo*Y{`!1Wo!Mlo3}kkq5J-2x z3{fqBl9ET4c;t~s#QOE?#n)edtv>?*2>UeBUy|m0fKrnKFw3(I5^)jLzsR;@`U7M| z#G7xvIsevMZ-uEcs$1OfkFlSVGV7E8YAnA+F*Q|SwYRUx6gw&l{cxP%n~?}A9}&fr zCytA#&`+^oJNyGsaiYtme9kMn-EJByty5HEb&|~osdb(j8doee?j2-LK##2Dx4A+~ zdHwa*BSJx>XC8tBXDbd5(wt=lEk&*j+lz&r!cDn{|o~Fsv*umxmwrBFh<-9n*k>ICjS?w8& z^uTke@SMH zO*)0)wh?g;$}74eiBbv8<61PgsU)=C~%0BK|n@jPOp$ROdia$yw3?15pP2@L8gg2b1R zx8xW=jS2&$Vjxcfrc5f5)>>~nJVXpilt|cK83PnCwOwe1Wh7%+HvuFMs;ZM?Q$jl1 z+bk-sw`VAOWCLzEfl|z!T(1l8G3#q;h>i2~JgF_NfsqHmLb-IXv$LJ%+?%OiH(>Ug z@0GIgV;;Y>erFA@gAH#e_*h?1$ufY7L9(c+ia3x_6`)d$QKb&)dbyaATa9ZBNJ>om zDFcn8)h+-T_7B+Ysi^8`5>P?qdr1j$sHey3T$YbcbpQv1HV^FI?{wgYBBY+cN*ip7 z-bc}>6aJ=_vZb3$3A=agYJ@BBI>p1bNDcviBG7)H6ipxN`Vj2(-M@D){A+Qar@p%K zQv0w(dBlcelf89cs7!Hn2jB_+r>DEylBe1KIR{EAOJT*{7$wv*!v%#QtCn$-1sI!+ zHI`zDLk6HpO?9_I{BW)cf{deG>1tPUF>%_1sRiV`2I}$#_S!KOCBC}T-1%Jhr{!_` zX~0agU#4GA-GC`D$VQM!N!7!QVuq(Ic!0%ZdQSR*9}Yv5EY zwIQo8<&+HeFpL2T52qwAQUG?f%Wb$>U)eMn)kk&wK(z;?k^Pel!bT>Hx#0N9ngC{y zf?dV#6|D~c-bzc*JrvYI;Sp{7huJ;^J|n!G9>5UN!-%HNs}hQDc_`6FqOb6f&58W zuet3MHk8|Mr^DYj@NW41IaZ^nOmYopdTHE%$bd1nj79l4KUO9o z6)I)wXT0&D;+2$8PXq?1!K(7HbAgDmRra@<@$^zu|8f0nnhg{`Sku^GfFKS0eqh@m zMi@*0+-kX1+LIJc5-$)11W>UP$=vjf`xvNW>2!~FZ#5Y;zj^cKo#vJ`&$c(T;gf&; z;Pm&OtKU2_YD@{)-l*7Ai~UJwAEN|_S*D&+eMmS`8_APz+=TF8VoJ?aQ-LWt)>&U< z*pdk6SzxsR+FTjc3sg_je%8w0EZ;cF135Sflqg2=Tf38(Rc}C7gOB5MaS+c5P*MyeK?1;}C~&S= zU{i23G`>sP!%IssiJV}nt|1@L>1((Nv766!-d{@OknEvyi8q3F8RC=!IbiRtB zPy2h-v}x1$O#;;vD~FuV?l&Kq?OAp3Vu4Rm&|4X*J;OkQAgepp8R}Im-AtDfpNuGneo(5*@UV)bMscWyj_WwTo@WXe~ zCNKf?uZfDic+Wleh)+NL6q-^OJIi@{4dsVX)&fW5r1);2-+&2=H^pP~v~izK>5pjn zJ}M?pAyw7;!N=W1J}OJEVS$u5i?rEG@3`X*yhI%Cl6F~TChEuyBD880i_IzMWt6hL ziQGU9vQoB$bPu~}mjP0MErSfLUiEhrP^HcOh9@hqS|VE%wSnhe061;NHn){qwru$^ zc7d>r=Kw15=Z9f9p9W|NW%bqJqY)%5>>rmdUHWPQfURJYU|S@%$z{$!KE7oFu>OfY z==4JJg}02+b;F3={kumWeH7<-^(IdW=Ld}_Y&R&JkM(_kY@m4`(Z&CxT{d&)&6_7S zZrli-)30bLZx&;hu=z&#=P> zAKJqB(PHZIy3@ZL@P}NMj(uNV%h*)Rs8kFPFqc#Lam05;G7O_kHkXM4tq!JYbj<}e zsi>w&Npn#}(oueNajoCddwqLJ+0-UH0cVMSK$RJM~m=J=<5g9zyA8`t36HfOS8eHv}2L9Wpz~!3p;7J@qHb9DG$^%%>jjh zx-w_7iTcj6i~-hi%7p)?P{JAX;nVO*i(H(Z7OgM9c7j0iT>{NIyx%wNy}giQG4M3W z;J*sc=%BQZRf?~D5pA>z z{Ygue7DXb}2V1m?C2eYa5T*Xrv;`%gs8|Gv2%;8$D>k?O^zO{~9dd@5d)VYQVOMiu zmwcT0V|Vu6eD|C=b7p2Cz{2!|xDz->Xw?65dggPGWC(;=OJqoiD#?m}c3|#->`ahU z)w~7`_!3AM{+S|K#WN=-CkgWkl!qn@B-t_B7*ARUM0}jhT1p@Z^?`tEU+{pUPZS(K zYmhsv5JDNjB~4DZ1p@2o=*PL_H#BwJS$Qtq}%m5vJ%N7XMT7L*)CGfK} zb&FBi^%N%Qi@c^~25_R|fDm~brwIx{yl)ekrz;CkeTMT_s6b)7}moMLmH)uJCo*Z3VUTnizdKnZP3%~>3}d@@AgLc^|46kBV&L); zv~|o&l3HsY$N8u`L%DVkHg(jMXv9YZn(}U1_^vro_7MbU@k))~Dz?rhHU|vxZk*Q5p7n$;S zC+f>{$ZnD+jzh!03leXEML}g{lT>aXZn#{tl~KyGWP3LA$tOT0eQ01{U~^iR&3t@6 zYf)~Lfuu&MQ%zUb=BJmO`5kfBQyXn`iw9O~3r$GzcjlK?(ql7V^Lw{um-yf1R0C`HE z>Fw?P0_Na*crIyk8n=>$o%Nn_*%tas?9-|>lw2|8Y~RC3}OVO$pa zF$k~d)<91A-XQ5CIQK`BvxN_ms${({M1$Km=(N7WhYy#bvE|fLy72r8Oz(Usqr}vp zTC~@wMJpFGS+fL-HA}^1OkAy4a+(Njn2k!1Qi*^zXSu_9j6AYjo|6QctPPuv$^efv zNe8L*8@Y4+8?A5IIsGxC!c@`KXg-3b=N34VMuwg5uZX9T5EnpP1uO$D1 zpE*4a*~etUF;J-3rM`gt#hTYwI%w8gAscc`y50FV z@6c+zCP0l&L}qE_emWlX01_wUY?}_}piWQIBq z3&`o2RMVyeXUW7Q&H5_jEsza4CVkQI+-r>*9q9Fa8Mw`Xe|e%U6=^urI*;OX)My#k zXIxFv+hm$1C9523igl;fCqWM>VO^Y0wQN#5xu~4sqr4V!7n60WCP0nO2k*agk5>1C zP(vVFcOac%xfn2prJ9ynCo5}IGJR4Mm2|ReMFUyI_|)deCuT3DeUUb0xF`=o_Ct#v zsR>Y{(~a[y]("/")[0][q](":")&&(a=k+f[2][B](0,f[2].lastIndexOf("/"))+"/"+a):a=k+f[2]+(a||Be);d.href=a;e=c(d);return{protocol:(d[A]||"")[D](),host:e[0], -port:e[1],path:e[2],Oa:d[va]||"",url:a||""}}function Na(a,b){function c(b,c){a.contains(b)||a.set(b,[]);a.get(b)[n](c)}for(var d=Da(b)[y]("&"),e=0;ef?c(d[e],"1"):c(d[e][B](0,f),d[e][B](f+1))}}function Pa(a,b){if(F(a)||"["==a[ma](0)&&"]"==a[ma](a[w]-1))return"-";var c=J.domain;return a[q](c+(b&&"/"!=b?b:""))==(0==a[q]("http://")?7:0==a[q]("https://")?8:0)?"0":a};var Qa=0;function Ra(a,b,c){1<=Qa||1<=100*m.random()||ld()||(a=["utmt=error","utmerr="+a,"utmwv=5.6.3","utmn="+Ea(),"utmsp=1"],b&&a[n]("api="+b),c&&a[n]("msg="+G(c[B](0,100))),M.w&&a[n]("aip=1"),Sa(a[C]("&")),Qa++)};var Ta=0,Ua={};function N(a){return Va("x"+Ta++,a)}function Va(a,b){Ua[a]=!!b;return a} -var Wa=N(),Xa=Va("anonymizeIp"),Ya=N(),$a=N(),ab=N(),bb=N(),O=N(),P=N(),cb=N(),db=N(),eb=N(),fb=N(),gb=N(),hb=N(),ib=N(),jb=N(),kb=N(),lb=N(),nb=N(),ob=N(),pb=N(),qb=N(),rb=N(),sb=N(),tb=N(),ub=N(),vb=N(),wb=N(),xb=N(),yb=N(),zb=N(),Ab=N(),Bb=N(),Cb=N(),Db=N(),Eb=N(),Fb=N(!0),Gb=Va("currencyCode"),Hb=Va("page"),Ib=Va("title"),Jb=N(),Kb=N(),Lb=N(),Mb=N(),Nb=N(),Ob=N(),Pb=N(),Qb=N(),Rb=N(),Q=N(!0),Sb=N(!0),Tb=N(!0),Ub=N(!0),Vb=N(!0),Wb=N(!0),Zb=N(!0),$b=N(!0),ac=N(!0),bc=N(!0),cc=N(!0),R=N(!0),dc=N(!0), -ec=N(!0),fc=N(!0),gc=N(!0),hc=N(!0),ic=N(!0),jc=N(!0),S=N(!0),kc=N(!0),lc=N(!0),mc=N(!0),nc=N(!0),oc=N(!0),pc=N(!0),qc=N(!0),rc=Va("campaignParams"),sc=N(),tc=Va("hitCallback"),uc=N();N();var vc=N(),wc=N(),xc=N(),yc=N(),zc=N(),Ac=N(),Bc=N(),Cc=N(),Dc=N(),Ec=N(),Fc=N(),Gc=N(),Hc=N(),Ic=N();N();var Mc=N(),Nc=N(),Yb=N(),Jc=N(),Kc=N(),Lc=Va("utmtCookieName"),Cd=Va("displayFeatures"),Oc=N(),of=Va("gtmid"),Oe=Va("uaName"),Pe=Va("uaDomain"),Qe=Va("uaPath"),pf=Va("linkid");var Re=function(){function a(a,c,d){T(qf[x],a,c,d)}a("_createTracker",qf[x].r,55);a("_getTracker",qf[x].oa,0);a("_getTrackerByName",qf[x].u,51);a("_getTrackers",qf[x].pa,130);a("_anonymizeIp",qf[x].aa,16);a("_forceSSL",qf[x].la,125);a("_getPlugin",Pc,120)},Se=function(){function a(a,c,d){T(U[x],a,c,d)}Qc("_getName",$a,58);Qc("_getAccount",Wa,64);Qc("_visitCode",Q,54);Qc("_getClientInfo",ib,53,1);Qc("_getDetectTitle",lb,56,1);Qc("_getDetectFlash",jb,65,1);Qc("_getLocalGifPath",wb,57);Qc("_getServiceMode", -xb,59);V("_setClientInfo",ib,66,2);V("_setAccount",Wa,3);V("_setNamespace",Ya,48);V("_setAllowLinker",fb,11,2);V("_setDetectFlash",jb,61,2);V("_setDetectTitle",lb,62,2);V("_setLocalGifPath",wb,46,0);V("_setLocalServerMode",xb,92,void 0,0);V("_setRemoteServerMode",xb,63,void 0,1);V("_setLocalRemoteServerMode",xb,47,void 0,2);V("_setSampleRate",vb,45,1);V("_setCampaignTrack",kb,36,2);V("_setAllowAnchor",gb,7,2);V("_setCampNameKey",ob,41);V("_setCampContentKey",tb,38);V("_setCampIdKey",nb,39);V("_setCampMediumKey", -rb,40);V("_setCampNOKey",ub,42);V("_setCampSourceKey",qb,43);V("_setCampTermKey",sb,44);V("_setCampCIdKey",pb,37);V("_setCookiePath",P,9,0);V("_setMaxCustomVariables",yb,0,1);V("_setVisitorCookieTimeout",cb,28,1);V("_setSessionCookieTimeout",db,26,1);V("_setCampaignCookieTimeout",eb,29,1);V("_setReferrerOverride",Jb,49);V("_setSiteSpeedSampleRate",Dc,132);a("_trackPageview",U[x].Fa,1);a("_trackEvent",U[x].F,4);a("_trackPageLoadTime",U[x].Ea,100);a("_trackSocial",U[x].Ga,104);a("_trackTrans",U[x].Ia, -18);a("_sendXEvent",U[x].t,78);a("_createEventTracker",U[x].ia,74);a("_getVersion",U[x].qa,60);a("_setDomainName",U[x].B,6);a("_setAllowHash",U[x].va,8);a("_getLinkerUrl",U[x].na,52);a("_link",U[x].link,101);a("_linkByPost",U[x].ua,102);a("_setTrans",U[x].za,20);a("_addTrans",U[x].$,21);a("_addItem",U[x].Y,19);a("_clearTrans",U[x].ea,105);a("_setTransactionDelim",U[x].Aa,82);a("_setCustomVar",U[x].wa,10);a("_deleteCustomVar",U[x].ka,35);a("_getVisitorCustomVar",U[x].ra,50);a("_setXKey",U[x].Ca,83); -a("_setXValue",U[x].Da,84);a("_getXKey",U[x].sa,76);a("_getXValue",U[x].ta,77);a("_clearXKey",U[x].fa,72);a("_clearXValue",U[x].ga,73);a("_createXObj",U[x].ja,75);a("_addIgnoredOrganic",U[x].W,15);a("_clearIgnoredOrganic",U[x].ba,97);a("_addIgnoredRef",U[x].X,31);a("_clearIgnoredRef",U[x].ca,32);a("_addOrganic",U[x].Z,14);a("_clearOrganic",U[x].da,70);a("_cookiePathCopy",U[x].ha,30);a("_get",U[x].ma,106);a("_set",U[x].xa,107);a("_addEventListener",U[x].addEventListener,108);a("_removeEventListener", -U[x].removeEventListener,109);a("_addDevId",U[x].V);a("_getPlugin",Pc,122);a("_setPageGroup",U[x].ya,126);a("_trackTiming",U[x].Ha,124);a("_initData",U[x].v,2);a("_setVar",U[x].Ba,22);V("_setSessionTimeout",db,27,3);V("_setCookieTimeout",eb,25,3);V("_setCookiePersistence",cb,24,1);a("_setAutoTrackOutbound",Fa,79);a("_setTrackOutboundSubdomains",Fa,81);a("_setHrefExamineLimit",Fa,80)};function Pc(a){var b=this.plugins_;if(b)return b.get(a)} -var T=function(a,b,c,d){a[b]=function(){try{return void 0!=d&&H(d),c[ya](this,arguments)}catch(a){throw Ra("exc",b,a&&a[r]),a;}}},Qc=function(a,b,c,d){U[x][a]=function(){try{return H(c),Aa(this.a.get(b),d)}catch(e){throw Ra("exc",a,e&&e[r]),e;}}},V=function(a,b,c,d,e){U[x][a]=function(f){try{H(c),void 0==e?this.a.set(b,Aa(f,d)):this.a.set(b,e)}catch(Be){throw Ra("exc",a,Be&&Be[r]),Be;}}},Te=function(a,b){return{type:b,target:a,stopPropagation:function(){throw"aborted";}}};var Rc=new RegExp(/(^|\.)doubleclick\.net$/i),Sc=function(a,b){return Rc[ia](J[z].hostname)?!0:"/"!==b?!1:0!=a[q]("www.google.")&&0!=a[q](".google.")&&0!=a[q]("google.")||-1b[w]||ad(b[0],c))return!1;b=b[ja](1)[C](".")[y]("|");0=b[w])return!0; -b=b[1][y](-1==b[1][q](",")?"^":",");for(c=0;cb[w]||ad(b[0],c))return a.set(ec,void 0),a.set(fc,void 0),a.set(gc,void 0),a.set(ic,void 0),a.set(jc,void 0),a.set(nc,void 0),a.set(oc,void 0),a.set(pc,void 0),a.set(qc,void 0),a.set(S,void 0),a.set(kc,void 0),a.set(lc,void 0),a.set(mc,void 0),!1;a.set(ec,1*b[1]);a.set(fc,1*b[2]);a.set(gc,1*b[3]);Ve(a,b[ja](4)[C]("."));return!0},Ve=function(a,b){function c(a){return(a=b[oa](a+"=(.*?)(?:\\|utm|$)"))&& -2==a[w]?a[1]:void 0}function d(b,c){c?(c=e?I(c):c[y]("%20")[C](" "),a.set(b,c)):a.set(b,void 0)}-1==b[q]("=")&&(b=I(b));var e="2"==c("utmcvr");d(ic,c("utmcid"));d(jc,c("utmccn"));d(nc,c("utmcsr"));d(oc,c("utmcmd"));d(pc,c("utmctr"));d(qc,c("utmcct"));d(S,c("utmgclid"));d(kc,c("utmgclsrc"));d(lc,c("utmdclid"));d(mc,c("utmdsid"))},ad=function(a,b){return b?a!=b:!/^\d+$/[ia](a)};var Uc=function(){this.filters=[]};Uc[x].add=function(a,b){this.filters[n]({name:a,s:b})};Uc[x].cb=function(a){try{for(var b=0;b=100*a.get(vb)&&a[ta]()}function kd(a){ld(a.get(Wa))&&a[ta]()}function md(a){"file:"==J[z][A]&&a[ta]()}function Ge(a){He()&&a[ta]()}function nd(a){a.get(Ib)||a.set(Ib,J.title,!0);a.get(Hb)||a.set(Hb,J[z].pathname+J[z][va],!0)} -function lf(a){a.get(Wa)&&"UA-XXXXX-X"!=a.get(Wa)||a[ta]()};var od=new function(){var a=[];this.set=function(b){a[b]=!0};this.encode=function(){for(var b=[],c=0;c=b[0]||0>=b[1]?"":b[C]("x");a.Wa=d}catch(k){H(135)}qd=a}},td=function(){sd();for(var a= -qd,b=W[za],a=b.appName+b.version+a.language+b.platform+b.userAgent+a.javaEnabled+a.Q+a.P+(J.cookie?J.cookie:"")+(J.referrer?J.referrer:""),b=a[w],c=W.history[w];0d?(this.i=b[B](0,d),this.l=b[B](d+1,c),this.h=b[B](c+1)):(this.i=b[B](0,d),this.h=b[B](d+1));this.k=a[ja](1);this.Ma=!this.l&&"_require"==this.h;this.J=!this.i&&!this.l&&"_provide"==this.h}},Y=function(){T(Y[x],"push",Y[x][n],5);T(Y[x],"_getPlugin",Pc,121);T(Y[x], -"_createAsyncTracker",Y[x].Sa,33);T(Y[x],"_getAsyncTracker",Y[x].Ta,34);this.I=new nf;this.p=[]};E=Y[x];E.Na=function(a,b,c){var d=this.I.get(a);if(!Ba(d))return!1;b.plugins_=b.plugins_||new nf;b.plugins_.set(a,new d(b,c||{}));return!0};E.push=function(a){var b=Z.Va[ya](this,arguments),b=Z.p.concat(b);for(Z.p=[];0e?b+"#"+d:b+"&"+d;c="";f=b[q]("?");0f?b+"?"+d+c:b+"&"+d+c},$d=function(a,b,c,d){for(var e=0;3>e;e++){for(var f=0;3>f;f++){if(d==Yc(a+b+c))return H(127),[b,c]; -var Be=b[p](/ /g,"%20"),k=c[p](/ /g,"%20");if(d==Yc(a+Be+k))return H(128),[Be,k];Be=Be[p](/\+/g,"%20");k=k[p](/\+/g,"%20");if(d==Yc(a+Be+k))return H(129),[Be,k];try{var Ja=b[oa]("utmctr=(.*?)(?:\\|utm|$)");if(Ja&&2==Ja[w]&&(Be=b[p](Ja[1],G(I(Ja[1]))),d==Yc(a+Be+c)))return H(139),[Be,c]}catch(t){}b=I(b)}c=I(c)}};var de="|",fe=function(a,b,c,d,e,f,Be,k,Ja){var t=ee(a,b);t||(t={},a.get(Cb)[n](t));t.id_=b;t.affiliation_=c;t.total_=d;t.tax_=e;t.shipping_=f;t.city_=Be;t.state_=k;t.country_=Ja;t.items_=t.items_||[];return t},ge=function(a,b,c,d,e,f,Be){a=ee(a,b)||fe(a,b,"",0,0,0,"","","");var k;t:{if(a&&a.items_){k=a.items_;for(var Ja=0;Jab[w]||!/^\d+$/[ia](b[0])||(b[0]=""+c,Fd(a,"__utmx",b[C]("."),void 0))},be=function(a,b){var c=$c(a.get(O),pd("__utmx"));"-"==c&&(c="");return b?G(c):c},Ye=function(a){try{var b=La(J[z][xa],!1),c=ea(L(b.d.get("utm_referrer")))||"";c&&a.set(Jb,c);var d=ea(K(b.d.get("utm_expid")))||"";d&&(d=d[y](".")[0],a.set(Oc,""+d))}catch(e){H(146)}},l=function(a){var b=W.gaData&&W.gaData.expId;b&&a.set(Oc,""+b)};var ke=function(a,b){var c=m.min(a.b(Dc,0),100);if(a.b(Q,0)%100>=c)return!1;c=Ze()||$e();if(void 0==c)return!1;var d=c[0];if(void 0==d||d==ba||da(d))return!1;0a[b])return!1;return!0},le=function(a){return da(a)|| -0>a?0:5E3>a?10*m[la](a/10):5E4>a?100*m[la](a/100):41E5>a?1E3*m[la](a/1E3):41E5},je=function(a){for(var b=new yd,c=0;cc[w])){for(var d=[],e=0;e=f)return!1;c=1*(""+c);if(""==a||!wd(a)||""==b||!wd(b)||!xd(c)||da(c)||0>c||0>f||100=a||a>e.get(yb))a=!1;else if(!b||!c||128=a&&Ca(b)&&""!=b){var c=this.get(Fc)||[];c[a]=b;this.set(Fc,c)}};E.V=function(a){a=""+a;if(a[oa](/^[A-Za-z0-9]{1,5}$/)){var b=this.get(Ic)||[];b[n](a);this.set(Ic,b)}};E.v=function(){this.a[ka]()};E.Ba=function(a){a&&""!=a&&(this.set(Tb,a),this.a.j("var"))};var ne=function(a){"trans"!==a.get(sc)&&500<=a.b(cc,0)&&a[ta]();if("event"===a.get(sc)){var b=(new Date)[g](),c=a.b(dc,0),d=a.b(Zb,0),c=m[la]((b-(c!=d?c:1E3*c))/1E3*1);0=a.b(R,0)&&a[ta]()}},pe=function(a){"event"===a.get(sc)&&a.set(R,m.max(0,a.b(R,10)-1))};var qe=function(){var a=[];this.add=function(b,c,d){d&&(c=G(""+c));a[n](b+"="+c)};this.toString=function(){return a[C]("&")}},re=function(a,b){(b||2!=a.get(xb))&&a.Za(cc)},se=function(a,b){b.add("utmwv","5.6.3");b.add("utms",a.get(cc));b.add("utmn",Ea());var c=J[z].hostname;F(c)||b.add("utmhn",c,!0);c=a.get(vb);100!=c&&b.add("utmsp",c,!0)},te=function(a,b){b.add("utmht",(new Date)[g]());b.add("utmac",Da(a.get(Wa)));a.get(Oc)&&b.add("utmxkey",a.get(Oc),!0);a.get(vc)&&b.add("utmni",1);a.get(of)&&b.add("utmgtm", -a.get(of),!0);var c=a.get(Ic);c&&0=a[w])gf(a,b,c);else if(8192>=a[w]){if(0<=W[za].userAgent[q]("Firefox")&&![].reduce)throw new De(a[w]);df(a,b)||ef(a,b)||Ee(a,b)||b()}else throw new Ce(a[w]);},gf=function(a,b,c){c=c||Ne()+"/__utm.gif?";var d=new Image(1,1);d.src=c+ -a;Ie(d,function(){Ie(d,null);Je(d,null);b()});Je(d,function(){Ie(d,null);Je(d,null);b()})},ef=function(a,b){var c;c=W.XDomainRequest;if(!c)return!1;c=new c;c.open("POST",Ne()+"/p/__utm.gif");Je(c,function(){b()});Ie(c,b);c.send(a);return!0},df=function(a,b){var c=W.XMLHttpRequest;if(!c)return!1;var d=new c;if(!("withCredentials"in d))return!1;d.open("POST",Ne()+"/p/__utm.gif",!0);d.withCredentials=!0;d.setRequestHeader("Content-Type","text/plain");d.onreadystatechange=function(){4==d.readyState&& -(b(),d=null)};d.send(a);return!0},Ee=function(a,b){if(!J.body)return We(function(){Ee(a,b)},100),!0;a=aa(a);try{var c=J[qa]('')}catch(d){c=J[qa]("iframe"),ha(c,a)}c.height="0";c.width="0";c.style.display="none";c.style.visibility="hidden";var e=Ne()+"/u/post_iframe.html";Ga(W,"beforeunload",function(){c.src="";c.parentNode&&c.parentNode.removeChild(c)});ca(b,1E3);J.body.appendChild(c);c.src=e;return!0};var qf=function(){this.G=this.w=!1;0==Ea()%1E4&&(H(142),this.G=!0);this.C={};this.D=[];this.U=0;this.S=[["www.google-analytics.com","","/plugins/"]];this._gasoCPath=this._gasoDomain=this.bb=void 0;Re();Se()};E=qf[x];E.oa=function(a,b){return this.r(a,void 0,b)};E.r=function(a,b,c){b&&H(23);c&&H(67);void 0==b&&(b="~"+M.U++);a=new U(b,a,c);M.C[b]=a;M.D[n](a);return a};E.u=function(a){a=a||"";return M.C[a]||M.r(void 0,a)};E.pa=function(){return M.D[ja](0)};E.ab=function(){return M.D[w]}; -E.aa=function(){this.w=!0};E.la=function(){this.G=!0};var Fe=function(a){if("prerender"==J.visibilityState)return!1;a();return!0};var M=new qf;var Ha=W._gat;Ha&&Ba(Ha._getTracker)?M=Ha:W._gat=M;var Z=new Y;(function(a){if(!Fe(a)){H(123);var b=!1,c=function(){if(!b&&Fe(a)){b=!0;var d=J,e=c;d.removeEventListener?d.removeEventListener("visibilitychange",e,!1):d.detachEvent&&d.detachEvent("onvisibilitychange",e)}};Ga(J,"visibilitychange",c)}})(function(){var a=W._gaq,b=!1;if(a&&Ba(a[n])&&(b="[object Array]"==Object[x][v].call(Object(a)),!b)){Z=a;return}W._gaq=Z;b&&Z[n][ya](Z,a)});function Yc(a){var b=1,c=0,d;if(a)for(b=0,d=a[w]-1;0<=d;d--)c=a.charCodeAt(d),b=(b<<6&268435455)+c+(c<<14),c=b&266338304,b=0!=c?b^c>>21:b;return b};})(); diff --git a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/jquery.js b/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/jquery.js deleted file mode 100644 index 944268604..000000000 --- a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/jquery.js +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - Error: Not Found – Trac | QCubed PHP5 Rapid Development Framework - - - - - - - - - - - - - - - - - -
- -
-

Error: Not Found

-

File js/jquery.js not found

-

- TracGuide — The Trac User and Administration Guide -

-
-
- - - - - - \ No newline at end of file diff --git a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/search.js b/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/search.js deleted file mode 100644 index 5ba8e48ca..000000000 --- a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/search.js +++ /dev/null @@ -1,62 +0,0 @@ -(function($){ - - /* Adapted from http://www.kryogenix.org/code/browser/searchhi/ */ - $.fn.highlightText = function(text, className) { - function highlight(node) { - if (node.nodeType == 3) { // Node.TEXT_NODE - var val = node.nodeValue; - var pos = val.toLowerCase().indexOf(text); - if (pos >= 0 && !$.className.has(node.parentNode, className)) { - var span = document.createElement("span"); - span.className = className; - var txt = document.createTextNode(val.substr(pos, text.length)); - span.appendChild(txt); - node.parentNode.insertBefore(span, node.parentNode.insertBefore( - document.createTextNode(val.substr(pos + text.length)), - node.nextSibling)); - node.nodeValue = val.substr(0, pos); - } - } else if (!$(node).is("button, select, textarea")) { - $.each(node.childNodes, function() { highlight(this) }); - } - } - return this.each(function() { highlight(this) }); - } - - $(document).ready(function() { - var elems = $(".searchable"); - if (!elems.length) return; - - function getSearchTerms(url) { - if (url.indexOf("?") == -1) return []; - var params = url.substr(url.indexOf("?") + 1).split("&"); - for (var p in params) { - var param = params[p].split("="); - if (param.length < 2) continue; - if (param[0] == "q" || param[0] == "p") {// q= for Google, p= for Yahoo - var query = decodeURIComponent(param[1].replace(/\+/g, " ")); - if (query[0] == "!") query = query.slice(1); - var terms = []; - $.each(query.split(/(".*?"|'.*?'|\s+)/), function() { - if (terms.length < 10) { - term = this.replace(/^\s+$/, "") - .replace(/^['"]/, "") - .replace(/['"]$/, ""); - if (term.length >= 3) - terms.push(term); - } - }); - return terms; - } - } - return []; - } - - var terms = getSearchTerms(document.URL); - if (!terms.length) terms = getSearchTerms(document.referrer); - $.each(terms, function(idx) { - elems.highlightText(this.toLowerCase(), "searchword" + (idx % 5)); - }); - }); - -})(jQuery); diff --git a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/style.css b/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/style.css deleted file mode 100644 index 8fb9463e5..000000000 --- a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/style.css +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - Error: Not Found – Trac | QCubed PHP5 Rapid Development Framework - - - - - - - - - - - - - - - - - -
- -
-

Error: Not Found

-

File style.css not found

-

- TracGuide — The Trac User and Administration Guide -

-
-
- - - - - - \ No newline at end of file diff --git a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac(1).css b/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac(1).css deleted file mode 100644 index 70c1c3793..000000000 --- a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac(1).css +++ /dev/null @@ -1,121 +0,0 @@ -div.code pre .hll { background-color: #ffffcc } -div.code pre { background: #ffffff; } -div.code pre .c { color: #999988; font-style: italic } /* Comment */ -div.code pre .err { color: #a61717; background-color: #e3d2d2 } /* Error */ -div.code pre .k { font-weight: bold } /* Keyword */ -div.code pre .o { font-weight: bold } /* Operator */ -div.code pre .cm { color: #999988; font-style: italic } /* Comment.Multiline */ -div.code pre .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ -div.code pre .c1 { color: #999988; font-style: italic } /* Comment.Single */ -div.code pre .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ -div.code pre .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ -div.code pre .ge { font-style: italic } /* Generic.Emph */ -div.code pre .gr { color: #aa0000 } /* Generic.Error */ -div.code pre .gh { color: #999999 } /* Generic.Heading */ -div.code pre .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ -div.code pre .go { color: #888888 } /* Generic.Output */ -div.code pre .gp { color: #555555 } /* Generic.Prompt */ -div.code pre .gs { font-weight: bold } /* Generic.Strong */ -div.code pre .gu { color: #aaaaaa } /* Generic.Subheading */ -div.code pre .gt { color: #aa0000 } /* Generic.Traceback */ -div.code pre .kc { font-weight: bold } /* Keyword.Constant */ -div.code pre .kd { font-weight: bold } /* Keyword.Declaration */ -div.code pre .kn { font-weight: bold } /* Keyword.Namespace */ -div.code pre .kp { font-weight: bold } /* Keyword.Pseudo */ -div.code pre .kr { font-weight: bold } /* Keyword.Reserved */ -div.code pre .kt { color: #445588; font-weight: bold } /* Keyword.Type */ -div.code pre .m { color: #009999 } /* Literal.Number */ -div.code pre .s { color: #bb8844 } /* Literal.String */ -div.code pre .na { color: #008080 } /* Name.Attribute */ -div.code pre .nb { color: #999999 } /* Name.Builtin */ -div.code pre .nc { color: #445588; font-weight: bold } /* Name.Class */ -div.code pre .no { color: #008080 } /* Name.Constant */ -div.code pre .ni { color: #800080 } /* Name.Entity */ -div.code pre .ne { color: #990000; font-weight: bold } /* Name.Exception */ -div.code pre .nf { color: #990000; font-weight: bold } /* Name.Function */ -div.code pre .nn { color: #555555 } /* Name.Namespace */ -div.code pre .nt { color: #000080 } /* Name.Tag */ -div.code pre .nv { color: #008080 } /* Name.Variable */ -div.code pre .ow { font-weight: bold } /* Operator.Word */ -div.code pre .w { color: #bbbbbb } /* Text.Whitespace */ -div.code pre .mf { color: #009999 } /* Literal.Number.Float */ -div.code pre .mh { color: #009999 } /* Literal.Number.Hex */ -div.code pre .mi { color: #009999 } /* Literal.Number.Integer */ -div.code pre .mo { color: #009999 } /* Literal.Number.Oct */ -div.code pre .sb { color: #bb8844 } /* Literal.String.Backtick */ -div.code pre .sc { color: #bb8844 } /* Literal.String.Char */ -div.code pre .sd { color: #bb8844 } /* Literal.String.Doc */ -div.code pre .s2 { color: #bb8844 } /* Literal.String.Double */ -div.code pre .se { color: #bb8844 } /* Literal.String.Escape */ -div.code pre .sh { color: #bb8844 } /* Literal.String.Heredoc */ -div.code pre .si { color: #bb8844 } /* Literal.String.Interpol */ -div.code pre .sx { color: #bb8844 } /* Literal.String.Other */ -div.code pre .sr { color: #808000 } /* Literal.String.Regex */ -div.code pre .s1 { color: #bb8844 } /* Literal.String.Single */ -div.code pre .ss { color: #bb8844 } /* Literal.String.Symbol */ -div.code pre .bp { color: #999999 } /* Name.Builtin.Pseudo */ -div.code pre .vc { color: #008080 } /* Name.Variable.Class */ -div.code pre .vg { color: #008080 } /* Name.Variable.Global */ -div.code pre .vi { color: #008080 } /* Name.Variable.Instance */ -div.code pre .il { color: #009999 } /* Literal.Number.Integer.Long */ - -table.code td .hll { background-color: #ffffcc } -table.code td { background: #ffffff; } -table.code td .c { color: #999988; font-style: italic } /* Comment */ -table.code td .err { color: #a61717; background-color: #e3d2d2 } /* Error */ -table.code td .k { font-weight: bold } /* Keyword */ -table.code td .o { font-weight: bold } /* Operator */ -table.code td .cm { color: #999988; font-style: italic } /* Comment.Multiline */ -table.code td .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ -table.code td .c1 { color: #999988; font-style: italic } /* Comment.Single */ -table.code td .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ -table.code td .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ -table.code td .ge { font-style: italic } /* Generic.Emph */ -table.code td .gr { color: #aa0000 } /* Generic.Error */ -table.code td .gh { color: #999999 } /* Generic.Heading */ -table.code td .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ -table.code td .go { color: #888888 } /* Generic.Output */ -table.code td .gp { color: #555555 } /* Generic.Prompt */ -table.code td .gs { font-weight: bold } /* Generic.Strong */ -table.code td .gu { color: #aaaaaa } /* Generic.Subheading */ -table.code td .gt { color: #aa0000 } /* Generic.Traceback */ -table.code td .kc { font-weight: bold } /* Keyword.Constant */ -table.code td .kd { font-weight: bold } /* Keyword.Declaration */ -table.code td .kn { font-weight: bold } /* Keyword.Namespace */ -table.code td .kp { font-weight: bold } /* Keyword.Pseudo */ -table.code td .kr { font-weight: bold } /* Keyword.Reserved */ -table.code td .kt { color: #445588; font-weight: bold } /* Keyword.Type */ -table.code td .m { color: #009999 } /* Literal.Number */ -table.code td .s { color: #bb8844 } /* Literal.String */ -table.code td .na { color: #008080 } /* Name.Attribute */ -table.code td .nb { color: #999999 } /* Name.Builtin */ -table.code td .nc { color: #445588; font-weight: bold } /* Name.Class */ -table.code td .no { color: #008080 } /* Name.Constant */ -table.code td .ni { color: #800080 } /* Name.Entity */ -table.code td .ne { color: #990000; font-weight: bold } /* Name.Exception */ -table.code td .nf { color: #990000; font-weight: bold } /* Name.Function */ -table.code td .nn { color: #555555 } /* Name.Namespace */ -table.code td .nt { color: #000080 } /* Name.Tag */ -table.code td .nv { color: #008080 } /* Name.Variable */ -table.code td .ow { font-weight: bold } /* Operator.Word */ -table.code td .w { color: #bbbbbb } /* Text.Whitespace */ -table.code td .mf { color: #009999 } /* Literal.Number.Float */ -table.code td .mh { color: #009999 } /* Literal.Number.Hex */ -table.code td .mi { color: #009999 } /* Literal.Number.Integer */ -table.code td .mo { color: #009999 } /* Literal.Number.Oct */ -table.code td .sb { color: #bb8844 } /* Literal.String.Backtick */ -table.code td .sc { color: #bb8844 } /* Literal.String.Char */ -table.code td .sd { color: #bb8844 } /* Literal.String.Doc */ -table.code td .s2 { color: #bb8844 } /* Literal.String.Double */ -table.code td .se { color: #bb8844 } /* Literal.String.Escape */ -table.code td .sh { color: #bb8844 } /* Literal.String.Heredoc */ -table.code td .si { color: #bb8844 } /* Literal.String.Interpol */ -table.code td .sx { color: #bb8844 } /* Literal.String.Other */ -table.code td .sr { color: #808000 } /* Literal.String.Regex */ -table.code td .s1 { color: #bb8844 } /* Literal.String.Single */ -table.code td .ss { color: #bb8844 } /* Literal.String.Symbol */ -table.code td .bp { color: #999999 } /* Name.Builtin.Pseudo */ -table.code td .vc { color: #008080 } /* Name.Variable.Class */ -table.code td .vg { color: #008080 } /* Name.Variable.Global */ -table.code td .vi { color: #008080 } /* Name.Variable.Instance */ -table.code td .il { color: #009999 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac.css b/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac.css deleted file mode 100644 index 9ebe189f0..000000000 --- a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac.css +++ /dev/null @@ -1,576 +0,0 @@ -body { background: #fff; color: #000; margin: 10px; padding: 0; } -body, th, td { - font: normal 13px Verdana,Arial,'Bitstream Vera Sans',Helvetica,sans-serif; -} -h1, h2, h3, h4 { - font-family: Arial,Verdana,'Bitstream Vera Sans',Helvetica,sans-serif; - font-weight: bold; - letter-spacing: -0.018em; - page-break-after: avoid; -} -h1 { font-size: 19px; margin: .15em 1em 0.5em 0 } -h2 { font-size: 16px } -h3 { font-size: 14px } -hr { border: none; border-top: 1px solid #ccb; margin: 2em 0 } -address { font-style: normal } -img { border: none } - -.underline { text-decoration: underline } -ol.loweralpha { list-style-type: lower-alpha } -ol.upperalpha { list-style-type: upper-alpha } -ol.lowerroman { list-style-type: lower-roman } -ol.upperroman { list-style-type: upper-roman } -ol.arabic { list-style-type: decimal } - -/* Link styles */ -:link, :visited { - text-decoration: none; - color: #b00; - border-bottom: 1px dotted #bbb; -} -:link:hover, :visited:hover { background-color: #eee; color: #555 } -h1 :link, h1 :visited ,h2 :link, h2 :visited, h3 :link, h3 :visited, -h4 :link, h4 :visited, h5 :link, h5 :visited, h6 :link, h6 :visited { - color: inherit; -} -.trac-rawlink { border-bottom: none } - -/* Heading anchors */ -.anchor:link, .anchor:visited { - border: none; - color: #d7d7d7; - font-size: .8em; - vertical-align: text-top; -} -* > .anchor:link, * > .anchor:visited { - visibility: hidden; -} -h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, -h4:hover .anchor, h5:hover .anchor, h6:hover .anchor { - visibility: visible; -} - -@media screen { - a.ext-link .icon { - background: url(../extlink.gif) center center no-repeat; - padding-left: 12px; - } - a.mail-link .icon { - background: url(../envelope.png) center center no-repeat; - padding-left: 14px; - } -} - -/* Forms */ -input, textarea, select { margin: 2px } -input, select { vertical-align: middle } -input[type=button], input[type=submit], input[type=reset] { - background: #eee; - color: #222; - border: 1px outset #ccc; - padding: .1em .5em; -} -input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover { - background: #ccb; -} -input[type=button][disabled], input[type=submit][disabled], -input[type=reset][disabled] { - background: #f6f6f6; - border-style: solid; - color: #999; -} -input[type=text], input.textwidget, textarea { border: 1px solid #d7d7d7 } -input[type=text], input.textwidget { padding: .25em .5em } -input[type=text]:focus, input.textwidget:focus, textarea:focus { - border: 1px solid #886; -} -option { border-bottom: 1px dotted #d7d7d7 } -fieldset { border: 1px solid #d7d7d7; padding: .5em; margin: 1em 0 } -form p.hint, form span.hint { color: #666; font-size: 85%; font-style: italic; margin: .5em 0; - padding-left: 1em; -} -fieldset.iefix { - background: transparent; - border: none; - padding: 0; - margin: 0; -} -* html fieldset.iefix { width: 98% } -fieldset.iefix p { margin: 0 } -legend { color: #999; padding: 0 .25em; font-size: 90%; font-weight: bold } -label.disabled { color: #d7d7d7 } -.buttons { margin: .5em .5em .5em 0 } -.buttons form, .buttons form div { display: inline } -.buttons input { margin: 1em .5em .1em 0 } -.inlinebuttons input { - font-size: 70%; - border-width: 1px; - border-style: dotted; - margin: 0 .1em; - padding: 0.1em; - background: none; -} - -/* Header */ -#header hr { display: none } -#header h1 { margin: 1.5em 0 -1.5em; } -#header img { border: none; margin: 0 0 -3em } -#header :link, #header :visited, #header :link:hover, #header :visited:hover { - background: transparent; - color: #555; - margin-bottom: 2px; - border: none; -} -#header h1 :link:hover, #header h1 :visited:hover { color: #000 } - -/* Quick search */ -#search { - clear: both; - font-size: 10px; - height: 2.2em; - margin: 0 0 1em; - text-align: right; -} -#search input { font-size: 10px } -#search label { display: none } - -/* Navigation */ -.nav h2, .nav hr { display: none } -.nav ul { font-size: 10px; list-style: none; margin: 0; text-align: right } -.nav li { - border-right: 1px solid #d7d7d7; - display: inline; - padding: 0 .75em; - white-space: nowrap; -} -.nav li.last { border-right: none } - -/* Main navigation bar */ -#mainnav { - background: #f7f7f7 url(../topbar_gradient.png) 0 0; - border: 1px solid #000; - font: normal 10px verdana,'Bitstream Vera Sans',helvetica,arial,sans-serif; - margin: .66em 0 .33em; - padding: .2em 0; -} -#mainnav li { border-right: none; padding: .25em 0 } -#mainnav :link, #mainnav :visited { - background: url(../dots.gif) 0 0 no-repeat; - border-right: 1px solid #fff; - border-bottom: none; - border-left: 1px solid #555; - color: #000; - padding: .2em 20px; -} -* html #mainnav :link, * html #mainnav :visited { background-position: 1px 0 } -#mainnav :link:hover, #mainnav :visited:hover { - background-color: #ccc; - border-right: 1px solid #ddd; -} -#mainnav .active :link, #mainnav .active :visited { - background: #333 url(../topbar_gradient2.png) 0 0 repeat-x; - border-top: none; - border-right: 1px solid #000; - color: #eee; - font-weight: bold; -} -#mainnav .active :link:hover, #mainnav .active :visited:hover { - border-right: 1px solid #000; -} - -/* Context-dependent navigation links */ -#ctxtnav { height: 1em } -#ctxtnav li ul { - background: #f7f7f7; - color: #ccc; - border: 1px solid; - padding: 0; - display: inline; - margin: 0; -} -#ctxtnav li li { padding: 0; } -#ctxtnav li li :link, #ctxtnav li li :visited { padding: 0 1em } -#ctxtnav li li :link:hover, #ctxtnav li li :visited:hover { - background: #bba; - color: #fff; -} - -/* Alternate links */ -#altlinks { clear: both; text-align: center } -#altlinks h3 { font-size: 12px; letter-spacing: normal; margin: 0 } -#altlinks ul { list-style: none; margin: 0; padding: 0 0 1em } -#altlinks li { - border-right: 1px solid #d7d7d7; - display: inline; - font-size: 11px; - line-height: 1.5; - padding: 0 1em; - white-space: nowrap; -} -#altlinks li.last { border-right: none } -#altlinks li :link, #altlinks li :visited { - background-repeat: no-repeat; - color: #666; - border: none; - padding: 0 0 2px; -} -#altlinks li a.ics { background-image: url(../ics.png); padding-left: 22px } -#altlinks li a.rss { background-image: url(../feed.png); padding-left: 20px } - -/* Footer */ -#footer { - clear: both; - color: #bbb; - font-size: 10px; - border-top: 1px solid; - height: 31px; - padding: .25em 0; -} -#footer :link, #footer :visited { color: #bbb; } -#footer hr { display: none } -#footer #tracpowered { border: 0; float: left } -#footer #tracpowered:hover { background: transparent } -#footer p { margin: 0 } -#footer p.left { - float: left; - margin-left: 1em; - padding: 0 1em; - border-left: 1px solid #d7d7d7; - border-right: 1px solid #d7d7d7; -} -#footer p.right { - float: right; - text-align: right; -} - -#content { padding-bottom: 2em; position: relative } - -#help { - clear: both; - color: #999; - font-size: 90%; - margin: 1em; - text-align: right; -} -#help :link, #help :visited { cursor: help } -#help hr { display: none } - -/* Page preferences form */ -#prefs { - background: #f7f7f0; - border: 1px outset #998; - float: right; - font-size: 9px; - padding: .8em; - position: relative; - margin: 0 1em 1em; -} -* html #prefs { width: 26em } /* Set width only for IE */ -#prefs input, #prefs select { font-size: 9px; vertical-align: middle } -#prefs fieldset { - background: transparent; - border: none; - margin: .5em; - padding: 0; -} -#prefs fieldset legend { - background: transparent; - color: #000; - font-size: 9px; - font-weight: normal; - margin: 0 0 0 -1.5em; - padding: 0; -} -#prefs .buttons { text-align: right } - -/* Version information (browser, wiki, attachments) */ -#info { - margin: 1em 0 0 0; - background: #f7f7f0; - border: 1px solid #d7d7d7; - border-collapse: collapse; - border-spacing: 0; - clear: both; - width: 100%; -} -#info th, #info td { font-size: 85%; padding: 2px .5em; vertical-align: top } -#info th { font-weight: bold; text-align: left; white-space: nowrap } -#info td.message { width: 100% } -#info .message ul { padding: 0; margin: 0 2em } -#info .message p { margin: 0; padding: 0 } - -/* Wiki */ -.wikipage { padding-left: 18px } -.wikipage h1, .wikipage h2, .wikipage h3 { margin-left: -18px } - -a.missing:link, a.missing:visited, a.missing, span.missing, -a.forbidden, span.forbidden { color: #998 } -a.missing:hover { color: #000 } -a.closed:link, a.closed:visited, span.closed { text-decoration: line-through } - -/* User-selectable styles for blocks */ -.important { - background: #fcb; - border: 1px dotted #d00; - color: #500; - padding: 0 .5em 0 .5em; - margin: .5em; -} - -dl.wiki dt { font-weight: bold } -dl.compact dt { float: left; padding-right: .5em } -dl.compact dd { margin: 0; padding: 0 } - -pre.wiki, pre.literal-block { - background: #f7f7f7; - border: 1px solid #d7d7d7; - margin: 1em 1.75em; - padding: .25em; - overflow: auto; -} - -blockquote.citation { - margin: -0.6em 0; - border-style: solid; - border-width: 0 0 0 2px; - padding-left: .5em; - border-color: #b44; -} -.citation blockquote.citation { border-color: #4b4; } -.citation .citation blockquote.citation { border-color: #44b; } -.citation .citation .citation blockquote.citation { border-color: #c55; } - -table.wiki { - border: 2px solid #ccc; - border-collapse: collapse; - border-spacing: 0; -} -table.wiki td { border: 1px solid #ccc; padding: .1em .25em; } - -.wikitoolbar { - margin-top: 0.3em; - margin-left: 2px; - border: solid #d7d7d7; - border-width: 1px 1px 1px 0; - height: 18px; - width: 234px; -} -.wikitoolbar :link, .wikitoolbar :visited { - background: transparent url(../edit_toolbar.png) no-repeat; - border: 1px solid #fff; - border-left-color: #d7d7d7; - cursor: default; - display: block; - float: left; - width: 24px; - height: 16px; -} -.wikitoolbar :link:hover, .wikitoolbar :visited:hover { - background-color: transparent; - border: 1px solid #fb2; -} -.wikitoolbar a#em { background-position: 0 0 } -.wikitoolbar a#strong { background-position: 0 -16px } -.wikitoolbar a#heading { background-position: 0 -32px } -.wikitoolbar a#link { background-position: 0 -48px } -.wikitoolbar a#code { background-position: 0 -64px } -.wikitoolbar a#hr { background-position: 0 -80px } -.wikitoolbar a#np { background-position: 0 -96px } -.wikitoolbar a#br { background-position: 0 -112px } -.wikitoolbar a#img { background-position: 0 -128px } - -/* Styles for the form for adding attachments. */ -#attachment .field { margin-top: 1.3em } -#attachment label { padding-left: .2em } -#attachment fieldset { margin-top: 2em } -#attachment fieldset .field { float: left; margin: 0 1em .5em 0 } -#attachment .options { float: left; padding: 0 0 1em 1em } -#attachment br { clear: left } -.attachment #preview { margin-top: 1em } - -/* Styles for the list of attachments. */ -#attachments { border: 1px outset #996; padding: 1em } -#attachments .attachments { margin-left: 2em; padding: 0 } -#attachments dt { display: list-item; list-style: square; } -#attachments dd { font-style: italic; margin-left: 0; padding-left: 0; } - -/* Styles for tabular listings such as those used for displaying directory - contents and report results. */ -table.listing { - clear: both; - border-bottom: 1px solid #d7d7d7; - border-collapse: collapse; - border-spacing: 0; - margin-top: 1em; - width: 100%; -} -table.listing th { text-align: left; padding: 0 1em .1em 0; font-size: 12px } -table.listing thead { background: #f7f7f0 } -table.listing thead th { - border: 1px solid #d7d7d7; - border-bottom-color: #999; - font-size: 11px; - font-weight: bold; - padding: 2px .5em; - vertical-align: bottom; -} -table.listing thead th :link:hover, table.listing thead th :visited:hover { - background-color: transparent; -} -table.listing thead th a { border: none; padding-right: 12px } -table.listing th.asc a, table.listing th.desc a { font-weight: bold } -table.listing th.asc a, table.listing th.desc a { - background-position: 100% 50%; - background-repeat: no-repeat; -} -table.listing th.asc a { background-image: url(../asc.png) } -table.listing th.desc a { background-image: url(../desc.png) } -table.listing tbody td, table.listing tbody th { - border: 1px dotted #ddd; - padding: .3em .5em; - vertical-align: top; -} -table.listing tbody td a:hover, table.listing tbody th a:hover { - background-color: transparent; -} -table.listing tbody tr { border-top: 1px solid #ddd } -table.listing tbody tr.even { background-color: #fcfcfc } -table.listing tbody tr.odd { background-color: #f7f7f7 } -table.listing tbody tr:hover { background: #eed !important } -table.listing tbody tr.focus { background: #ddf !important } - -/* Styles for the page history table - (extends the styles for "table.listing") */ -#fieldhist td { padding: 0 .5em } -#fieldhist td.date, #fieldhist td.diff, #fieldhist td.version, -#fieldhist td.author { - white-space: nowrap; -} -#fieldhist td.version { text-align: center } -#fieldhist td.comment { width: 100% } - -/* Auto-completion interface */ -.suggestions { background: #fff; border: 1px solid #886; color: #222; } -.suggestions ul { - font-family: sans-serif; - max-height: 20em; - min-height: 3em; - list-style: none; - margin: 0; - overflow: auto; - padding: 0; - width: 440px; -} -* html .suggestions ul { height: 10em; } -.suggestions li { background: #fff; cursor: pointer; padding: 2px 5px } -.suggestions li.selected { background: #b9b9b9 } - -/* Styles for the error page (and rst errors) */ -#content.error .message, div.system-message { - background: #fdc; - border: 2px solid #d00; - color: #500; - padding: .5em; - margin: 1em 0; -} -#content.error div.message pre, div.system-message pre { - margin-left: 1em; - overflow: hidden; - white-space: normal; -} -div.system-message p { margin: 0; } -div.system-message p.system-message-title { font-weight: bold; } - -#warning.system-message { background: #ffb; border: 1px solid #000; } -#warning.system-message li { list-style-type: square; } - -#notice.system-message { background: #dfd; border: 1px solid #000; } -#notice.system-message li { list-style-type: square; } - -#content.error form.newticket { display: inline; } -#content.error form.newticket textarea { display: none; } - -#content.error #systeminfo { margin: 1em; width: auto; } -#content.error #systeminfo th { font-weight: bold; text-align: right; } - -#content.error #traceback { margin-left: 1em; } -#content.error #traceback :link, #content.error #traceback :visited { - border: none; -} -#content.error #tbtoggle { font-size: 80%; } -#content.error #traceback div { margin-left: 1em; } -#content.error #traceback h3 { font-size: 95%; margin: .5em 0 0; } -#content.error #traceback :link var, #content.error #traceback :visited var { - font-family: monospace; - font-style: normal; - font-weight: bold; -} -#content.error #traceback span.file { color: #666; font-size: 85%; } -#content.error #traceback ul { list-style: none; margin: .5em 0; padding: 0; } -#content.error #traceback ol { - border: 1px dotted #d7d7d7; - color: #999; - font-size: 85%; - line-height: 1; - margin: .5em 0; -} -#content.error #traceback ol li { white-space: pre; } -#content.error #traceback ol li.current { background: #e6e6e6; color: #333; } -#content.error #traceback ol li code { color: #666; } -#content.error #traceback ol li.current code { color: #000; } -#content.error #traceback table { margin: .5em 0 1em; } -#content.error #traceback th, #content.error #traceback td { - font-size: 85%; padding: 1px; -} -#content.error #traceback th var { - font-family: monospace; - font-style: normal; -} -#content.error #traceback td code { white-space: pre; } -#content.error #traceback pre { font-size: 95%; } - -#content .paging { margin: 0 0 2em; padding: .5em 0 0; - font-size: 85%; line-height: 2em; text-align: center; -} -#content .paging .current { - padding: .1em .3em; - border: 1px solid #333; - background: #999; color: #fff; -} - -#content .paging :link, #content .paging :visited { - padding: .1em .3em; - border: 1px solid #666; - background: transparent; color: #666; -} -#content .paging :link:hover, #content .paging :visited:hover { - background: #999; color: #fff; border-color: #333; -} -#content .paging .previous a, -#content .paging .next a { - font-size: 150%; font-weight: bold; border: none; -} -#content .paging .previous a:hover, -#content .paging .next a:hover { - background: transparent; color: #666; -} - -#content h2 .numresults { color: #666; font-size: 90%; } - -/* Styles for search word highlighting */ -@media screen { - .searchword0 { background: #ff9 } - .searchword1 { background: #cfc } - .searchword2 { background: #cff } - .searchword3 { background: #ccf } - .searchword4 { background: #fcf } -} - -@media print { - #header, #altlinks, #footer, #help { display: none } - .nav, form, .buttons form, form .buttons, form .inlinebuttons, - .noprint, .trac-rawlink { - display: none; - } - form.printableform { display: block } -} diff --git a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac.js b/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac.js deleted file mode 100644 index fdcf40885..000000000 --- a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac.js +++ /dev/null @@ -1,75 +0,0 @@ -(function($){ - - $.fn.addAnchor = function(title) { - title = title || "Link here"; - return this.filter("*[id]").each(function() { - $(" \u00B6").attr("href", "#" + this.id) - .attr("title", title).appendTo(this); - }); - } - - $.fn.checked = function(checked) { - if (checked == undefined) { // getter - if (!this.length) return false; - return this.get(0).checked; - } else { // setter - return this.each(function() { - this.checked = checked; - }); - } - } - - $.fn.enable = function(enabled) { - if (enabled == undefined) enabled = true; - return this.each(function() { - this.disabled = !enabled; - var label = $(this).parents("label"); - if (!label.length && this.id) { - label = $("label[for='" + this.id + "']"); - } - if (!enabled) { - label.addClass("disabled"); - } else { - label.removeClass("disabled"); - } - }); - } - - $.loadStyleSheet = function(href, type) { - type = type || "text/css"; - $(document).ready(function() { - if (document.createStyleSheet) { // MSIE - document.createStyleSheet(href); - } else { - $("") - .appendTo("head"); - } - }); - } - - // Used for dynamically updating the height of a textarea - window.resizeTextArea = function (id, rows) { - var textarea = $("#" + id).get(0); - if (!textarea || textarea.rows == undefined) return; - textarea.rows = rows; - } - - // The following are defined for backwards compatibility with releases prior - // to Trac 0.11 - - window.addEvent = function(elem, type, func) { - $(elem).bind(type, func); - } - window.addHeadingLinks = function(container, title) { - $.each(["h1", "h2", "h3", "h4", "h5", "h6"], function() { - $(this, container).addAnchor(title); - }); - } - window.enableControl = function(id, enabled) { - $("#" + id).enable(enabled); - } - window.getAncestorByTagName = function(elem, tagName) { - return $(elem).parents(tagName).get(0); - } - -})(jQuery); \ No newline at end of file diff --git a/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac_logo_mini.png b/packages/myddas/examples/Attachment – Trac QCubed PHP5 Rapid Development Framework_files/trac_logo_mini.png deleted file mode 100644 index 38c038d64fa3c1d572f369d744da36768a1ca3e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 689 zcmV;i0#5yjP)dYU z{Qv*|^a>K50006oNklktk?2=xQjEDuQp@l_V-Mw!0MvQlSV((FlUT3Lfq3jN0y zj$rB_+!(rkDk|wCeK#t=wk~FQR0UHak61VgN9b~RiaCLv1JJIQwI+B%udKCXmabSK zpkND&q52-RSw=-(>=nX`qDLv3r zmQ)oCfOr!9nmxoe%dni7L$6Tl6CX}V)3Uus)DzYB^u&jerFjwxc*PociL1>X*dIL6 z@O;uk8&hAf;7~`;I(p)Q<@>E>VRJy*l*wyWLUltB2aj2vL7I~{YnxJO8mu6s14^-| z3m>qwOpn)Fq-KqKmddj+uRJk5sh3@5yR(B%w%lwT611`MEGbfzL)$(~D(q}1vG|7+ zD>DvQ>FNPfV?v6a?0mxh?Rk6?Tx^+mWG&o6 zI*t|1817klDf{VubLLDP*Vl;1G2*q|!)*>%mXyN> zS{Ux{{rYUY|D0>?U!h9ojO9_zx$u;Da{O`Iad+`1K1X{iyE3t#)GK)Qq@R7?hrb*D X?NO$K)J1bN00000NkvXXu0mjfXa+ [ 'ZERO DIVISOR ERROR- ~w' - [Where] ]. system_message(error(not_implemented(Type, What), Where)) --> [ '~w: ~w not implemented- ~w' - [Where, Type, What] ]. -system_message(error(operating_system_error, Where)) --> +system_message(error(operating_SYSTEM_ERROR_INTERNAL, Where)) --> [ 'OPERATING SYSTEM ERROR- ~w' - [Where] ]. system_message(error(out_of_heap_error, Where)) --> [ 'OUT OF DATABASE SPACE ERROR- ~w' - [Where] ]. diff --git a/pl/modules.yap b/pl/modules.yap index fe9cb35d2..6be66e2eb 100644 --- a/pl/modules.yap +++ b/pl/modules.yap @@ -580,7 +580,7 @@ source_module(Mod) :- '$is_mt'(HM, H, SM, B, IB, NSM), '$module_u_vars'(H,UVars,HM), % collect head variables in % expanded positions - '$expand_modules'(IB, B1, BO, HM, BM, NSM, UVars), + '$expand_modules'(IB, B1, BO, HM, BM, NSM, UVars-H), ('$full_clause_optimisation'(H, NSM, BO, BOO) -> true ; @@ -644,7 +644,7 @@ source_module(Mod) :- % % %'$expand_modules'(V,NG,NG,_,_,SM,HVars):-l writeln(V), fail. -'$expand_modules'(V,NG,NG,_,_,SM,HVars) :- +'$expand_modules'(V,NG,NG,_,_,SM,HVars-_) :- var(V), !, ( '$not_in_vars'(V,HVars) -> @@ -759,10 +759,10 @@ source_module(Mod) :- expand_goal(G, G) :- var(G), !. expand_goal(M:G, M:NG) :- - '$do_expand'(G, M, prolog, [], NG), !. + '$do_expand'(G, M, prolog, []-G, NG), !. expand_goal(G, NG) :- '$current_module'(Mod), - '$do_expand'(G, Mod, prolog, [], NG), !. + '$do_expand'(G, Mod, prolog, []-G, NG), !. expand_goal(G, G). '$do_expand'(G, _HM, _BM, _SM, _, G) :- var(G), !. @@ -818,11 +818,11 @@ expand_goal(G, G). '$do_expand'(G, HM, BM, SM, HVars, GI), GI \== G, !, '$expand_modules'(GI, G1, GO, HM, BM, SM, HVars). -'$complete_goal_expansion'(G, HM, BM, SM, G1, G2, _HVars) :- +'$complete_goal_expansion'(G, HM, BM, SM, G1, G2, _HVars-H) :- '$all_system_predicate'(G, BM, BM0), !, % make built-in processing transparent. '$match_mod'(G, HM, BM0, SM, G1), - '$c_built_in'(G1, SM, G2). + '$c_built_in'(G1, SM, H, G2). '$complete_goal_expansion'(G, HM, BM, SM, NG, NG, _) :- '$match_mod'(G, HM, BM, SM, NG). diff --git a/pl/preds.yap b/pl/preds.yap index e92013e0d..8c97cb2ff 100644 --- a/pl/preds.yap +++ b/pl/preds.yap @@ -772,21 +772,21 @@ clause_property(ClauseRef, file(FileName)) :- ( recorded('$mf','$mf_clause'(FileName,_Name,_Arity,_Module,ClauseRef),_R) -> true ; - '$instance_property'(ClauseRef, 2, FileName) ). + instance_property(ClauseRef, 2, FileName) ). clause_property(ClauseRef, source(FileName)) :- ( recorded('$mf','$mf_clause'(FileName,_Name,_Arity,_Module,ClauseRef),_R) -> true ; - '$instance_property'(ClauseRef, 2, FileName) ). + instance_property(ClauseRef, 2, FileName) ). clause_property(ClauseRef, line_count(LineNumber)) :- - '$instance_property'(ClauseRef, 4, LineNumber), + instance_property(ClauseRef, 4, LineNumber), LineNumber > 0. clause_property(ClauseRef, fact) :- - '$instance_property'(ClauseRef, 3, true). + instance_property(ClauseRef, 3, true). clause_property(ClauseRef, erased) :- - '$instance_property'(ClauseRef, 0, true). + instance_property(ClauseRef, 0, true). clause_property(ClauseRef, predicate(PredicateIndicator)) :- - '$instance_property'(ClauseRef, 1, PredicateIndicator). + instance_property(ClauseRef, 1, PredicateIndicator). '$set_predicate_attribute'(M:N/Ar, Flag, V) :- functor(P, N, Ar), diff --git a/pl/profile.yap b/pl/profile.yap index 65b0cab7b..65c1d57e9 100644 --- a/pl/profile.yap +++ b/pl/profile.yap @@ -205,7 +205,7 @@ showprofres(A) :- '$get_ppreds'([gprof(0,_,0)|Cls],Ps) :- !, '$get_ppreds'(Cls,Ps). '$get_ppreds'([gprof(0,_,Count)|_],_) :- !, - '$do_error'(system_error,showprofres(gprof(0,_,Count))). + '$do_error'(SYSTEM_ERROR_INTERNAL,showprofres(gprof(0,_,Count))). '$get_ppreds'([gprof(PProfInfo,_,Count0)|Cls],[Sum-(Mod:Name/Arity)|Ps]) :- '$get_more_ppreds'(Cls,PProfInfo,Count0,NCls,Sum), '$get_pred_pinfo'(PProfInfo,Mod,Name,Arity), diff --git a/pl/signals.yap b/pl/signals.yap index a0b4f8f37..4c7fdacd8 100644 --- a/pl/signals.yap +++ b/pl/signals.yap @@ -293,7 +293,7 @@ on_signal(Signal,OldAction,default) :- '$reset_signal'(Signal, OldAction). on_signal(_Signal,_OldAction,Action) :- var(Action), !, - throw(error(system_error,'Somehow the meta_predicate declarations of on_signal are subverted!')). + throw(error(SYSTEM_ERROR_INTERNAL,'Somehow the meta_predicate declarations of on_signal are subverted!')). on_signal(Signal,OldAction,Action) :- Action = (_:Goal), var(Goal), !, diff --git a/text.cpp b/text.cpp index 5885b17ee..89b7a5eed 100644 --- a/text.cpp +++ b/text.cpp @@ -237,7 +237,7 @@ readNumber( text = Yap_TermToString(Term t, NULL, size_t sz, NULL, ENC_UTF8, 0); } catch(const std::range_error& e) { - Yap_Error(SYSTEM_ERROR, TermNil, "failed to convert the number", s); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "failed to convert the number", s); return false; } } @@ -260,7 +260,7 @@ bool addText(Term t, int flags = 0, char *buf=NULL, size_t sz = 0, size_t *fsz = text = Yap_TermToString(Term t, buf, sz, fsz, ENC_UTF8, flags); } catch(const std::range_error& e) { - Yap_Error(SYSTEM_ERROR, TermNil, "failed to convert the number", s); + Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "failed to convert the number", s); return false; } } diff --git a/utf8proc/utf8proc.c b/utf8proc/utf8proc.c index 80f5ba8fd..75db20037 100644 --- a/utf8proc/utf8proc.c +++ b/utf8proc/utf8proc.c @@ -187,6 +187,10 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_encode_char(utf8proc_int32_t uc, ut } else return 0; } + + + + /* internal "unsafe" version that does not check whether uc is in range */ utf8proc_ssize_t unsafe_encode_char(utf8proc_int32_t uc, utf8proc_uint8_t *dst) { if (uc < 0x00) { diff --git a/utf8proc/utils.cmake b/utf8proc/utils.cmake index 63fc426a3..10f7ca643 100644 --- a/utf8proc/utils.cmake +++ b/utf8proc/utils.cmake @@ -2,7 +2,7 @@ function (disallow_intree_builds) # Adapted from LLVM's toplevel CMakeLists.txt file if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) - message(FATAL_ERROR " + message(SYSTEM_ERROR_FATAL " In-source builds are not allowed. CMake would overwrite the makefiles distributed with utf8proc. Please create a directory and run cmake from there. Building in a subdirectory is