More thread fixes, including true anonymous mqueues, worker_id for sequential,
support for arithmetic exceptions on mac, fixes for with_mutex, fixes for dangling pointers in thread termination. Uuufff...
This commit is contained in:
41
C/eval.c
41
C/eval.c
@@ -39,6 +39,9 @@ static char SccsId[] = "%W% %G%";
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if HAVE_FENV_H
|
||||
#include <fenv.h>
|
||||
#endif
|
||||
|
||||
static Term Eval(Term t1 USES_REGS);
|
||||
|
||||
@@ -92,6 +95,7 @@ get_matrix_element(Term t1, Term t2 USES_REGS)
|
||||
static Term
|
||||
Eval(Term t USES_REGS)
|
||||
{
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
LOCAL_ArithError = TRUE;
|
||||
return Yap_ArithError(INSTANTIATION_ERROR,t,"in arithmetic");
|
||||
@@ -167,12 +171,45 @@ Eval(Term t USES_REGS)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if HAVE_FENV_H
|
||||
Term
|
||||
Yap_InnerEval(Term t)
|
||||
Yap_InnerEval__(Term t USES_REGS)
|
||||
{
|
||||
#pragma STDC FENV_ACCESS ON
|
||||
int raised;
|
||||
Term ret;
|
||||
|
||||
feclearexcept(FE_ALL_EXCEPT);
|
||||
ret = Eval(t PASS_REGS);
|
||||
if ( ret && (raised = fetestexcept( FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)) ) {
|
||||
|
||||
feclearexcept(FE_ALL_EXCEPT);
|
||||
if (raised & FE_OVERFLOW) {
|
||||
LOCAL_Error_TYPE = EVALUATION_ERROR_FLOAT_OVERFLOW;
|
||||
} else if (raised & (FE_INVALID|FE_INEXACT)) {
|
||||
LOCAL_Error_TYPE = EVALUATION_ERROR_UNDEFINED;
|
||||
} else if (raised & FE_DIVBYZERO) {
|
||||
LOCAL_Error_TYPE = EVALUATION_ERROR_ZERO_DIVISOR;
|
||||
} else if (raised & FE_UNDERFLOW) {
|
||||
LOCAL_Error_TYPE = EVALUATION_ERROR_FLOAT_UNDERFLOW;
|
||||
} else {
|
||||
LOCAL_Error_TYPE = EVALUATION_ERROR_UNDEFINED;
|
||||
}
|
||||
LOCAL_Error_Term = t;
|
||||
LOCAL_ErrorMessage="Arithmetic Exception";
|
||||
return 0L;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
Term
|
||||
Yap_InnerEval__(Term t USES_REGS)
|
||||
{
|
||||
CACHE_REGS
|
||||
return Eval(t PASS_REGS);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BEAM
|
||||
Int BEAM_is(void);
|
||||
@@ -212,7 +249,7 @@ p_is( USES_REGS1 )
|
||||
{ /* X is Y */
|
||||
Term out = 0L;
|
||||
|
||||
while (!(out = Eval(Deref(ARG2) PASS_REGS))) {
|
||||
while (!(out = Yap_InnerEval(Deref(ARG2)))) {
|
||||
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) {
|
||||
|
Reference in New Issue
Block a user