fix log(0.0) and log10(0.0) to be SICStus compatible.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1245 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2005-02-18 21:34:02 +00:00
parent 755c60a7ca
commit 18f0de5486
13 changed files with 76 additions and 40 deletions

View File

@@ -343,12 +343,8 @@ p_log(Term t E_ARGS)
}
}
if (dbl > 0) {
if (dbl >= 0) {
RFLOAT(log(dbl));
} else if (dbl == 0) {
Yap_Error(DOMAIN_ERROR_NOT_ZERO, t, "log(%f)", dbl);
P = (yamop *)FAILCODE;
RERROR();
} else {
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t, "log(%f)", dbl);
P = (yamop *)FAILCODE;
@@ -401,12 +397,8 @@ p_log10(Term t E_ARGS)
}
}
if (dbl > 0) {
if (dbl >= 0) {
RFLOAT(log10(dbl));
} else if (dbl == 0) {
Yap_Error(DOMAIN_ERROR_NOT_ZERO, t, "log10(%f)", dbl);
P = (yamop *)FAILCODE;
RERROR();
} else {
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t, "log10(%f)", dbl);
P = (yamop *)FAILCODE;

View File

@@ -79,7 +79,7 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res)
Int j;
/* add a new attributed variable */
newv = (attvar_record *)Yap_ReadTimedVar(DelayedVars);
newv = DelayTop();
if (H0 - (CELL *)newv < 1024+(2*NUM_OF_ATTS))
return FALSE;
RESET_VARIABLE(&(newv->Done));
@@ -113,7 +113,7 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res)
}
*to_visit_ptr = to_visit;
*res = (CELL)&(newv->Done);
Yap_UpdateTimedVar(DelayedVars, (CELL)(newv->Atts+2*j));
SetDelayTop(attv->Atts+2*j);
return(TRUE);
}
@@ -342,7 +342,7 @@ BuildNewAttVar(Term t, Int i, Term tatt)
Term time;
int j;
attvar_record *attv = (attvar_record *)Yap_ReadTimedVar(DelayedVars);
attvar_record *attv = DelayTop();
if (H0 - (CELL *)attv < 1024+(2*NUM_OF_ATTS)) {
return FALSE;
}
@@ -356,7 +356,7 @@ BuildNewAttVar(Term t, Int i, Term tatt)
}
attv->NS = Yap_UpdateTimedVar(AttsMutableList, (CELL)&(attv->Done));
Bind((CELL *)t,(CELL)attv);
Yap_UpdateTimedVar(DelayedVars,(CELL)(attv->Atts+2*j));
SetDelayTop(attv->Atts+2*j);
/* avoid trouble in gc */
/* if i < 0 then we have the list of arguments */
if (i < 0) {

View File

@@ -1523,7 +1523,7 @@ Yap_InitYaamRegs(void)
Yap_StartSlots();
#if COROUTINING
RESET_VARIABLE((CELL *)Yap_GlobalBase);
DelayedVars = Yap_NewTimedVar((CELL)Yap_GlobalBase);
DelayedVars = Yap_NewTimedVar(MkIntTerm(0));
WokenGoals = Yap_NewTimedVar(TermNil);
MutableList = Yap_NewTimedVar(TermNil);
AttsMutableList = Yap_NewTimedVar(TermNil);

View File

@@ -21,6 +21,7 @@ static char SccsId[] = "%W% %G%";
#include "absmi.h"
#include "yapio.h"
#include "alloc.h"
#include "attvar.h"
#define EARLY_RESET 1
@@ -3335,13 +3336,13 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
effectiveness = 0;
gc_trace = FALSE;
#if COROUTINING
max = (CELL *)Yap_ReadTimedVar(DelayedVars);
if (H0 - max < 1024+(2*NUM_OF_ATTS)) {
max = (CELL *)DelayTop();
while (H0 - max < 1024+(2*NUM_OF_ATTS)) {
if (!Yap_growglobal(&current_env)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
return 0;
}
max = (CELL *)Yap_ReadTimedVar(DelayedVars);
max = (CELL *)DelayTop();
}
#else
max = NULL;
@@ -3404,7 +3405,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
current_env = (CELL *)*ASP;
ASP++;
#if COROUTINING
max = (CELL *)Yap_ReadTimedVar(DelayedVars);
max = (CELL *)DelayTop();
#endif
}
#endif
@@ -3427,7 +3428,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
current_env = (CELL *)*ASP;
ASP++;
#if COROUTINING
max = (CELL *)Yap_ReadTimedVar(DelayedVars);
max = (CELL *)DelayTop();
#endif
}
memset((void *)bp, 0, alloc_sz);

View File

@@ -467,7 +467,7 @@ unify_nvar:
unify_nvar_nvar:
/* both arguments are bound */
if (d0 == d1)
return (TRUE);
return TRUE;
if (IsPairTerm(d0)) {
if (!IsPairTerm(d1)) {
return (FALSE);
@@ -530,12 +530,12 @@ unify_var_nvar:
if (pt0 < H0) Yap_WakeUp(pt0);
bind_unify4:
#endif
return (TRUE);
return TRUE;
#if TRAILING_REQUIRES_BRANCH
unify_var_nvar_trail:
DO_TRAIL(pt0);
return (TRUE);
return TRUE;
#endif
deref_body(d1, pt1, unify_var_unk, unify_var_nvar);

View File

@@ -23,6 +23,7 @@ static char SccsId[] = "@(#)utilpreds.c 1.3";
#include "Heap.h"
#include "yapio.h"
#include "eval.h"
#include "attvar.h"
typedef struct {
Term old_var;
@@ -206,7 +207,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
CELL **bp[1];
if (dvars == NULL) {
dvars = (CELL *)Yap_ReadTimedVar(DelayedVars);
dvars = (CELL *)DelayTop();
}
if (ptd0 >= dvars) {
*ptf++ = (CELL) ptd0;
@@ -686,8 +687,10 @@ static Int
p_copy_term_no_delays(void) /* copy term t to a new instance */
{
Term t = CopyTermNoDelays(ARG1);
if (t == 0L)
if (t == 0L) {
printf("Error\n");
return FALSE;
}
/* be careful, there may be a stack shift here */
return(Yap_unify(ARG2,t));
}