diff --git a/C/absmi.c b/C/absmi.c index 8b9fc19c2..b25b8513a 100644 --- a/C/absmi.c +++ b/C/absmi.c @@ -2105,7 +2105,12 @@ absmi(int inp) } if (PrologMode & AbortMode) { PrologMode &= ~AbortMode; + ASP = Y+E_CB; + if (ASP > (CELL *)B) + ASP = (CELL *)B; + saveregs(); Error(PURE_ABORT, TermNil, ""); + setregs(); } JMPNext(); } diff --git a/C/errors.c b/C/errors.c index 726f98155..ec33b442a 100644 --- a/C/errors.c +++ b/C/errors.c @@ -315,7 +315,10 @@ Error (yap_error_number type, Term where, char *format,...) /* disallow recursive error handling */ if (PrologMode & InErrorMode) return(P); - if (type != PURE_ABORT) + /* PURE_ABORT may not have set where correctly */ + if (type == PURE_ABORT) + where = TermNil; + else where = Deref(where); if (IsVarTerm(where)) { /* we must be careful someone gave us a copy to a local variable */ diff --git a/C/sysbits.c b/C/sysbits.c index bfc4efeba..6c5287a8e 100644 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -1936,9 +1936,11 @@ static Int p_file_age(void) } /* wrapper for alarm system call */ -#if defined(_WIN32) +#if _MSC_VER || defined(__MINGW32__) + static VOID CALLBACK HandleTimer(LPVOID v, DWORD d1, DWORD d2) { /* force the system to creep */ + exit(0); p_creep (); /* now, say what is going on */ PutValue(AtomAlarm, MkAtomTerm(AtomTrue)); @@ -1960,16 +1962,25 @@ p_alarm(void) #if _MSC_VER || defined(__MINGW32__) { Term tout; - HANDLE htimer = CreateWaitableTimer(NULL,FALSE,NULL); - LARGE_INTEGER due_time; - __int64 timeout = -IntegerOfTerm(t); - due_time.QuadPart = timeout; + HANDLE htimer; + Int time = -IntegerOfTerm(t); + + if (time != 0) { + __int64 due_time; + LARGE_INTEGER liDueTime; - if (SetWaitableTimer(htimer, &due_time,0,HandleTimer,NULL,TRUE) == 0) { - Error(SYSTEM_ERROR, TermNil, - "alarm not available in this configuration"); - return(FALSE); - } + htimer = CreateWaitableTimer(NULL,FALSE,NULL); + due_time = time; + due_time *= 10000000; + /* Copy the relative time into a LARGE_INTEGER. */ + liDueTime.LowPart = (DWORD) ( due_time & 0xFFFFFFFF ); + liDueTime.HighPart = (LONG) ( due_time >> 32 ); + if (SetWaitableTimer(htimer, &liDueTime,0,HandleTimer,NULL,0) == 0) { + Error(SYSTEM_ERROR, TermNil, + "alarm not available in this configuration"); + return(FALSE); + } + } tout = MkIntegerTerm(0); return(unify(ARG2,tout)); }