fix global variables
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1962 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
d316ddeb2a
commit
c625347697
|
@ -1211,6 +1211,10 @@ p_nb_getval(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
READ_LOCK(ge->GRWLock);
|
READ_LOCK(ge->GRWLock);
|
||||||
to = ge->global;
|
to = ge->global;
|
||||||
|
if (IsVarTerm(to) && IsUnboundVar(VarOfTerm(to))) {
|
||||||
|
READ_UNLOCK(ge->GRWLock);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
READ_UNLOCK(ge->GRWLock);
|
READ_UNLOCK(ge->GRWLock);
|
||||||
return Yap_unify(ARG2, to);
|
return Yap_unify(ARG2, to);
|
||||||
}
|
}
|
||||||
|
|
40
C/grow.c
40
C/grow.c
|
@ -15,8 +15,7 @@
|
||||||
* *
|
* *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "Yap.h"
|
#include "absmi.h"
|
||||||
#include "Yatom.h"
|
|
||||||
#include "Heap.h"
|
#include "Heap.h"
|
||||||
#include "yapio.h"
|
#include "yapio.h"
|
||||||
#include "alloc.h"
|
#include "alloc.h"
|
||||||
|
@ -77,6 +76,27 @@ STATIC_PROTO(CELL AdjustPair, (CELL));
|
||||||
STATIC_PROTO(void AdjustStacksAndTrail, (void));
|
STATIC_PROTO(void AdjustStacksAndTrail, (void));
|
||||||
STATIC_PROTO(void AdjustRegs, (int));
|
STATIC_PROTO(void AdjustRegs, (int));
|
||||||
|
|
||||||
|
static void
|
||||||
|
LeaveGrowMode(prolog_exec_mode grow_mode)
|
||||||
|
{
|
||||||
|
Yap_PrologMode &= ~grow_mode;
|
||||||
|
if (Yap_PrologMode & AbortMode) {
|
||||||
|
Yap_PrologMode &= ~AbortMode;
|
||||||
|
Yap_Error(PURE_ABORT, TermNil, "");
|
||||||
|
/* in case someone mangles the P register */
|
||||||
|
save_machine_regs();
|
||||||
|
#if _MSC_VER || defined(__MINGW32__)
|
||||||
|
/* don't even think about trying this */
|
||||||
|
#else
|
||||||
|
#if PUSH_REGS
|
||||||
|
restore_absmi_regs(&Yap_standard_regs);
|
||||||
|
#endif
|
||||||
|
siglongjmp (Yap_RestartEnv, 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cpcellsd(register CELL *Dest, register CELL *Org, CELL NOf)
|
cpcellsd(register CELL *Dest, register CELL *Org, CELL NOf)
|
||||||
{
|
{
|
||||||
|
@ -717,7 +737,7 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit)
|
||||||
size = Yap_ExtendWorkSpaceThroughHole(size);
|
size = Yap_ExtendWorkSpaceThroughHole(size);
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
Yap_ErrorMessage = "Global Stack crashed against Local Stack";
|
Yap_ErrorMessage = "Global Stack crashed against Local Stack";
|
||||||
Yap_PrologMode &= ~GrowStackMode;
|
LeaveGrowMode(GrowStackMode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -809,7 +829,7 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit)
|
||||||
fprintf(Yap_stderr, "%% %cO took %g sec\n", vb_msg1, (double)growth_time/1000);
|
fprintf(Yap_stderr, "%% %cO took %g sec\n", vb_msg1, (double)growth_time/1000);
|
||||||
fprintf(Yap_stderr, "%% %cO Total of %g sec expanding stacks \n", vb_msg1, (double)total_delay_overflow_time/1000);
|
fprintf(Yap_stderr, "%% %cO Total of %g sec expanding stacks \n", vb_msg1, (double)total_delay_overflow_time/1000);
|
||||||
}
|
}
|
||||||
Yap_PrologMode &= ~GrowStackMode;
|
LeaveGrowMode(GrowStackMode);
|
||||||
if (hsplit)
|
if (hsplit)
|
||||||
return GDiff-GDiff0;
|
return GDiff-GDiff0;
|
||||||
else
|
else
|
||||||
|
@ -1181,11 +1201,11 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
|
||||||
UNLOCK(SignalLock);
|
UNLOCK(SignalLock);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
Yap_PrologMode &= ~GrowHeapMode;
|
LeaveGrowMode(GrowHeapMode);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
res=do_growheap(fix_code, in_size, (struct intermediates *)cip, NULL, NULL, NULL);
|
res=do_growheap(fix_code, in_size, (struct intermediates *)cip, NULL, NULL, NULL);
|
||||||
Yap_PrologMode &= ~GrowHeapMode;
|
LeaveGrowMode(GrowHeapMode);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1195,7 +1215,7 @@ Yap_growheap_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res=do_growheap(FALSE, 0L, NULL, old_trp, tksp, vep);
|
res=do_growheap(FALSE, 0L, NULL, old_trp, tksp, vep);
|
||||||
Yap_PrologMode &= ~GrowHeapMode;
|
LeaveGrowMode(GrowHeapMode);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1238,7 +1258,7 @@ Yap_growstack(long size)
|
||||||
|
|
||||||
Yap_PrologMode |= GrowStackMode;
|
Yap_PrologMode |= GrowStackMode;
|
||||||
res=growstack(size);
|
res=growstack(size);
|
||||||
Yap_PrologMode &= ~GrowStackMode;
|
LeaveGrowMode(GrowStackMode);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1396,7 +1416,7 @@ Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||||
fprintf(Yap_stderr, "%% Growing the stacks %ld bytes\n", (unsigned long int)size);
|
fprintf(Yap_stderr, "%% Growing the stacks %ld bytes\n", (unsigned long int)size);
|
||||||
}
|
}
|
||||||
if (!execute_growstack(size, FALSE, TRUE, old_trp, tksp, vep)) {
|
if (!execute_growstack(size, FALSE, TRUE, old_trp, tksp, vep)) {
|
||||||
Yap_PrologMode &= ~GrowStackMode;
|
LeaveGrowMode(GrowStackMode);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
growth_time = Yap_cputime()-start_growth_time;
|
growth_time = Yap_cputime()-start_growth_time;
|
||||||
|
@ -1405,7 +1425,7 @@ Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||||
fprintf(Yap_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
fprintf(Yap_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||||
fprintf(Yap_stderr, "%% Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
|
fprintf(Yap_stderr, "%% Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
|
||||||
}
|
}
|
||||||
Yap_PrologMode &= ~GrowStackMode;
|
LeaveGrowMode(GrowStackMode);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
37
C/heapgc.c
37
C/heapgc.c
|
@ -51,6 +51,7 @@ STATIC_PROTO(void compact_heap, (void));
|
||||||
STATIC_PROTO(void update_relocation_chain, (CELL *, CELL *));
|
STATIC_PROTO(void update_relocation_chain, (CELL *, CELL *));
|
||||||
STATIC_PROTO(int is_gc_verbose, (void));
|
STATIC_PROTO(int is_gc_verbose, (void));
|
||||||
STATIC_PROTO(int is_gc_very_verbose, (void));
|
STATIC_PROTO(int is_gc_very_verbose, (void));
|
||||||
|
STATIC_PROTO(void LeaveGCMode, (void));
|
||||||
#ifdef EASY_SHUNTING
|
#ifdef EASY_SHUNTING
|
||||||
STATIC_PROTO(void set_conditionals, (tr_fr_ptr));
|
STATIC_PROTO(void set_conditionals, (tr_fr_ptr));
|
||||||
#endif /* EASY_SHUNTING */
|
#endif /* EASY_SHUNTING */
|
||||||
|
@ -3855,7 +3856,7 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop)
|
||||||
/* expand the stack if effectiveness is less than 20 % */
|
/* expand the stack if effectiveness is less than 20 % */
|
||||||
if (ASP - H < gc_margin/sizeof(CELL) ||
|
if (ASP - H < gc_margin/sizeof(CELL) ||
|
||||||
effectiveness < 20) {
|
effectiveness < 20) {
|
||||||
Yap_PrologMode &= ~GCMode;
|
LeaveGCMode();
|
||||||
return Yap_growstack(gc_margin);
|
return Yap_growstack(gc_margin);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -3865,12 +3866,34 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
LeaveGCMode()
|
||||||
|
{
|
||||||
|
if (Yap_PrologMode & GCMode)
|
||||||
|
Yap_PrologMode &= ~GCMode;
|
||||||
|
if (Yap_PrologMode & AbortMode) {
|
||||||
|
Yap_PrologMode &= ~AbortMode;
|
||||||
|
Yap_Error(PURE_ABORT, TermNil, "");
|
||||||
|
/* in case someone mangles the P register */
|
||||||
|
save_machine_regs();
|
||||||
|
#if _MSC_VER || defined(__MINGW32__)
|
||||||
|
/* don't even think about trying this */
|
||||||
|
#else
|
||||||
|
#if PUSH_REGS
|
||||||
|
restore_absmi_regs(&Yap_standard_regs);
|
||||||
|
#endif
|
||||||
|
siglongjmp (Yap_RestartEnv, 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Yap_gc(Int predarity, CELL *current_env, yamop *nextop)
|
Yap_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
Yap_PrologMode |= GCMode;
|
Yap_PrologMode |= GCMode;
|
||||||
res=call_gc(4096, predarity, current_env, nextop);
|
res=call_gc(4096, predarity, current_env, nextop);
|
||||||
|
LeaveGCMode();
|
||||||
if (Yap_PrologMode & GCMode)
|
if (Yap_PrologMode & GCMode)
|
||||||
Yap_PrologMode &= ~GCMode;
|
Yap_PrologMode &= ~GCMode;
|
||||||
return res;
|
return res;
|
||||||
|
@ -3879,14 +3902,22 @@ Yap_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||||
int
|
int
|
||||||
Yap_gcl(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop)
|
Yap_gcl(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop)
|
||||||
{
|
{
|
||||||
return call_gc(gc_lim+CalculateStackGap()*sizeof(CELL), predarity, current_env, nextop);
|
int res;
|
||||||
|
Yap_PrologMode |= GCMode;
|
||||||
|
res = call_gc(gc_lim+CalculateStackGap()*sizeof(CELL), predarity, current_env, nextop);
|
||||||
|
LeaveGCMode();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_gc(void)
|
p_gc(void)
|
||||||
{
|
{
|
||||||
return do_gc(0, ENV, P) >= 0;
|
int res;
|
||||||
|
Yap_PrologMode |= GCMode;
|
||||||
|
res = do_gc(0, ENV, P) >= 0;
|
||||||
|
LeaveGCMode();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -11,8 +11,13 @@
|
||||||
* File: stdpreds.c *
|
* File: stdpreds.c *
|
||||||
* comments: General-purpose C implemented system predicates *
|
* comments: General-purpose C implemented system predicates *
|
||||||
* *
|
* *
|
||||||
* Last rev: $Date: 2007-10-10 09:44:24 $,$Author: vsc $ *
|
* Last rev: $Date: 2007-10-18 08:24:16 $,$Author: vsc $ *
|
||||||
* $Log: not supported by cvs2svn $
|
* $Log: not supported by cvs2svn $
|
||||||
|
* Revision 1.121 2007/10/10 09:44:24 vsc
|
||||||
|
* some more fixes to make YAP swi compatible
|
||||||
|
* fix absolute_file_name (again)
|
||||||
|
* fix setarg
|
||||||
|
*
|
||||||
* Revision 1.120 2007/10/08 23:02:15 vsc
|
* Revision 1.120 2007/10/08 23:02:15 vsc
|
||||||
* minor fixes
|
* minor fixes
|
||||||
*
|
*
|
||||||
|
@ -3952,7 +3957,7 @@ Yap_InitCPreds(void)
|
||||||
{
|
{
|
||||||
Term cm = CurrentModule;
|
Term cm = CurrentModule;
|
||||||
CurrentModule = SWI_MODULE;
|
CurrentModule = SWI_MODULE;
|
||||||
swi_install();
|
Yap_swi_install();
|
||||||
CurrentModule = cm;
|
CurrentModule = cm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1314,7 +1314,7 @@ InteractSIGINT(int ch) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
/* abort computation */
|
/* abort computation */
|
||||||
if (Yap_PrologMode & ConsoleGetcMode) {
|
if (Yap_PrologMode & (GCMode|ConsoleGetcMode|GrowStackMode|GrowHeapMode)) {
|
||||||
Yap_PrologMode |= AbortMode;
|
Yap_PrologMode |= AbortMode;
|
||||||
} else {
|
} else {
|
||||||
Yap_Error(PURE_ABORT, TermNil, "");
|
Yap_Error(PURE_ABORT, TermNil, "");
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
* File: Yap.proto *
|
* File: Yap.proto *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: Function declarations for YAP *
|
* comments: Function declarations for YAP *
|
||||||
* version: $Id: Yapproto.h,v 1.79 2007-05-14 16:44:12 vsc Exp $ *
|
* version: $Id: Yapproto.h,v 1.80 2007-10-18 08:24:16 vsc Exp $ *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
/* prototype file for Yap */
|
/* prototype file for Yap */
|
||||||
|
@ -403,6 +403,9 @@ void STD_PROTO(Yap_InitBackMYDDAS_SharedPreds,(void));
|
||||||
void STD_PROTO(Yap_InitMYDDAS_TopLevelPreds,(void));
|
void STD_PROTO(Yap_InitMYDDAS_TopLevelPreds,(void));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* yap2swi.c */
|
||||||
|
void STD_PROTO(Yap_swi_install,(void));
|
||||||
|
|
||||||
/* ypsocks.c */
|
/* ypsocks.c */
|
||||||
void STD_PROTO(Yap_InitSockets,(void));
|
void STD_PROTO(Yap_InitSockets,(void));
|
||||||
#ifdef USE_SOCKET
|
#ifdef USE_SOCKET
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
<h2>Yap-5.1.3:</h2>
|
<h2>Yap-5.1.3:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li> FIXED: delay abort until garbage collection or stack shifting is over.</li>
|
||||||
<li> FIXED: grow_trail assumed SREG points to stack top!</li>
|
<li> FIXED: grow_trail assumed SREG points to stack top!</li>
|
||||||
<li> FIXED: latest SWI chr.</li>
|
<li> FIXED: latest SWI chr.</li>
|
||||||
<li> FIXED: allow abolishing imports.</li>
|
<li> FIXED: allow abolishing imports.</li>
|
||||||
|
|
|
@ -1508,8 +1508,10 @@ SWI_ctime(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Yap_swi_install(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
swi_install(void)
|
Yap_swi_install(void)
|
||||||
{
|
{
|
||||||
YAP_UserCPredicate("ctime", SWI_ctime, 2);
|
YAP_UserCPredicate("ctime", SWI_ctime, 2);
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue