More interrupt handling cleanups!
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@104 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
362bf807a4
commit
efd998524f
14
C/absmi.c
14
C/absmi.c
@ -1977,7 +1977,7 @@ absmi(int inp)
|
||||
* *cannot* fail before having woken up all suspended goals.
|
||||
*/
|
||||
/* make sure we are here because of an awoken goal */
|
||||
if (CFREG == Unsigned(LCL0) && !(PrologMode & AbortMode)) {
|
||||
if (CFREG == Unsigned(LCL0) && !(PrologMode & (InterruptMode|AbortMode))) {
|
||||
Term WGs;
|
||||
Term my_goal;
|
||||
|
||||
@ -2051,11 +2051,17 @@ absmi(int inp)
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
if (PrologMode & AbortMode) {
|
||||
PrologMode &= ~AbortMode;
|
||||
if (PrologMode & (AbortMode|InterruptMode)) {
|
||||
CFREG = CalculateStackGap();
|
||||
/* same instruction */
|
||||
if (ProcessSIGINT() < 0) Abort("");
|
||||
if (PrologMode & InterruptMode) {
|
||||
PrologMode &= ~InterruptMode;
|
||||
ProcessSIGINT();
|
||||
}
|
||||
if (PrologMode & AbortMode) {
|
||||
PrologMode &= ~AbortMode;
|
||||
Abort("");
|
||||
}
|
||||
JMPNext();
|
||||
}
|
||||
#if SHADOW_S
|
||||
|
@ -211,6 +211,7 @@ Abort (char *format,...)
|
||||
va_list ap;
|
||||
va_start (ap, format);
|
||||
|
||||
PrologMode &= ~AbortMode;
|
||||
if (format)
|
||||
{
|
||||
char ch;
|
||||
|
3
C/init.c
3
C/init.c
@ -138,7 +138,8 @@ char FileNameBuf[YAP_FILENAME_MAX], FileNameBuf2[YAP_FILENAME_MAX];
|
||||
|
||||
/********* Prolog State ********************************************/
|
||||
|
||||
int PrologMode = BootMode;
|
||||
prolog_exec_mode PrologMode = BootMode;
|
||||
int CritLocks = 0;
|
||||
|
||||
#if PUSH_REGS
|
||||
REGSTORE standard_regs;
|
||||
|
21
C/iopreds.c
21
C/iopreds.c
@ -1196,26 +1196,23 @@ ConsoleGetc(int sno)
|
||||
strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
|
||||
newline = FALSE;
|
||||
}
|
||||
in_getc = TRUE;
|
||||
#if HAVE_SIGINTERRUPT
|
||||
siginterrupt(SIGINT, TRUE);
|
||||
#endif
|
||||
in_getc = TRUE;
|
||||
ch = YP_fgetc(s->u.file.file);
|
||||
in_getc = FALSE;
|
||||
#if HAVE_SIGINTERRUPT
|
||||
siginterrupt(SIGINT, FALSE);
|
||||
#endif
|
||||
in_getc = FALSE;
|
||||
if (PrologMode & AbortMode) {
|
||||
PrologMode &= ~AbortMode;
|
||||
CreepFlag = CalculateStackGap();
|
||||
if (ProcessSIGINT() < 0) Abort("");
|
||||
newline = TRUE;
|
||||
goto restart;
|
||||
} else if (ch == -1 && errno == EINTR) {
|
||||
errno = 0;
|
||||
PrologMode &= ~AbortMode;
|
||||
if (ProcessSIGINT() < 0) Abort("");
|
||||
if (PrologMode & InterruptMode) {
|
||||
PrologMode &= ~InterruptMode;
|
||||
ProcessSIGINT();
|
||||
newline = TRUE;
|
||||
if (PrologMode & AbortMode) {
|
||||
PrologMode &= ~AbortMode;
|
||||
Abort("");
|
||||
}
|
||||
goto restart;
|
||||
}
|
||||
return(console_post_process_read_char(ch, s, sno));
|
||||
|
32
C/sysbits.c
32
C/sysbits.c
@ -1076,7 +1076,7 @@ InteractSIGINT(char ch) {
|
||||
/* we can't do a direct abort, so ask the system to do
|
||||
it for us */
|
||||
p_creep();
|
||||
PutValue(AtomThrow, MkAtomTerm(AtomTrue));
|
||||
PrologMode |= AbortMode;
|
||||
return(-1);
|
||||
case 'c':
|
||||
/* continue */
|
||||
@ -1177,16 +1177,6 @@ ProcessSIGINT(void)
|
||||
{
|
||||
int ch, out;
|
||||
|
||||
#if HAVE_ISATTY
|
||||
if (!isatty(0)) {
|
||||
InteractSIGINT('e');
|
||||
}
|
||||
#if !HAVE_LIBREADLINE
|
||||
if (in_getc) {
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
do {
|
||||
#if HAVE_LIBREADLINE
|
||||
if (_line != (char *) NULL && _line != (char *) EOF)
|
||||
@ -1227,10 +1217,22 @@ HandleSIGINT (int sig)
|
||||
#endif
|
||||
{
|
||||
my_signal(SIGINT, HandleSIGINT);
|
||||
#if (_MSC_VER || defined(__MINGW32__))
|
||||
printf("hello\n");
|
||||
return;
|
||||
#if HAVE_ISATTY
|
||||
if (!isatty(0)) {
|
||||
InteractSIGINT('e');
|
||||
}
|
||||
#endif
|
||||
#if !HAVE_LIBREADLINE
|
||||
if (in_getc) {
|
||||
PrologMode |= InterruptMode;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (PrologMode & CritMode) {
|
||||
/* delay processing if we are messing with the Code space */
|
||||
PrologMode |= InterruptMode;
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_SETBUF
|
||||
/* make sure we are not waiting for the end of line */
|
||||
YP_setbuf (stdin, NULL);
|
||||
@ -1301,7 +1303,7 @@ MSCHandleSignal(DWORD dwCtrlType) {
|
||||
case CTRL_C_EVENT:
|
||||
case CTRL_BREAK_EVENT:
|
||||
p_creep();
|
||||
PrologMode |= AbortMode;
|
||||
PrologMode |= InterruptMode;
|
||||
return(TRUE);
|
||||
default:
|
||||
return(FALSE);
|
||||
|
@ -16,6 +16,11 @@
|
||||
|
||||
<h2>Yap-4.3.19:</h2>
|
||||
<ul>
|
||||
<li>FIXED: make ^c-a work within gc.</li>
|
||||
<li>FIXED: handle correctly very deep nested terms while gc
|
||||
marking.</li>
|
||||
<li>FIXED: ArityOfFunctor was giving trouble with HP-UX cc
|
||||
(Stasinos Konstantinos).</li>
|
||||
<li>FIXED: ^c works with Yap/MINGW32 (not in cygwin).</li>
|
||||
<li>FIXED: ^c a should never core dump.</li>
|
||||
<li>FIXED: comparison of variables in sub-terms.</li>
|
||||
|
59
m4/Yap.h.m4
59
m4/Yap.h.m4
@ -10,7 +10,7 @@
|
||||
* File: Yap.h.m4 *
|
||||
* mods: *
|
||||
* comments: main header file for YAP *
|
||||
* version: $Id: Yap.h.m4,v 1.5 2001-06-22 17:53:36 vsc Exp $ *
|
||||
* version: $Id: Yap.h.m4,v 1.6 2001-06-27 13:22:30 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
@ -754,14 +754,16 @@ extern int CurFileNo;
|
||||
|
||||
/********* Prolog may be in several modes *******************************/
|
||||
|
||||
#define BootMode 1 /* if booting or restoring */
|
||||
#define UserMode 2 /* Normal mode */
|
||||
#define CritMode 4 /* If we are meddling with the heap */
|
||||
#define FullLMode 8 /* to access the hidden atoms chain */
|
||||
#define AbortMode 16 /* expecting to abort */
|
||||
#define InterruptMode 32 /* under an interrupt */
|
||||
typedef enum {
|
||||
BootMode = 1, /* if booting or restoring */
|
||||
UserMode = 2, /* Normal mode */
|
||||
CritMode = 4, /* If we are meddling with the heap */
|
||||
AbortMode = 8, /* expecting to abort */
|
||||
InterruptMode = 16 /* under an interrupt */
|
||||
} prolog_exec_mode;
|
||||
|
||||
extern int PrologMode;
|
||||
extern prolog_exec_mode PrologMode;
|
||||
extern int CritLocks;
|
||||
|
||||
#if SIZEOF_INT_P==4
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
@ -802,17 +804,46 @@ extern int yap_argc;
|
||||
GLOBAL_LOCKS_who_locked_heap = worker_id; \
|
||||
} \
|
||||
PrologMode |= CritMode; \
|
||||
CritLocks++; \
|
||||
}
|
||||
#define YAPLeaveCriticalSection() \
|
||||
{ \
|
||||
if ((PrologMode ^= CritMode) & AbortMode) Abort((char *)NIL); \
|
||||
GLOBAL_LOCKS_who_locked_heap = MAX_WORKERS; \
|
||||
UNLOCK(GLOBAL_LOCKS_heap_access); \
|
||||
CritLocks--; \
|
||||
if (!CritLocks) { \
|
||||
PrologMode &= ~CritMode; \
|
||||
if (PrologMode & InterruptMode) { \
|
||||
PrologMode &= ~InterruptMode; \
|
||||
ProcessSIGINT(); \
|
||||
} \
|
||||
if (PrologMode & AbortMode) { \
|
||||
PrologMode &= ~AbortMode; \
|
||||
Abort(""); \
|
||||
} \
|
||||
GLOBAL_LOCKS_who_locked_heap = MAX_WORKERS; \
|
||||
UNLOCK(GLOBAL_LOCKS_heap_access); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define YAPEnterCriticalSection() PrologMode |= CritMode;
|
||||
#define YAPLeaveCriticalSection() \
|
||||
if((PrologMode ^= CritMode) & AbortMode) Abort((char *)NIL);
|
||||
#define YAPEnterCriticalSection() \
|
||||
{ \
|
||||
PrologMode |= CritMode; \
|
||||
CritLocks++; \
|
||||
}
|
||||
#define YAPLeaveCriticalSection() \
|
||||
{ \
|
||||
CritLocks--; \
|
||||
if (!CritLocks) { \
|
||||
PrologMode &= ~CritMode; \
|
||||
if (PrologMode & InterruptMode) { \
|
||||
PrologMode &= ~InterruptMode; \
|
||||
ProcessSIGINT(); \
|
||||
} \
|
||||
if (PrologMode & AbortMode) { \
|
||||
PrologMode &= ~AbortMode; \
|
||||
Abort(""); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#endif /* YAPOR */
|
||||
|
||||
/* when we are calling the InitStaff procedures */
|
||||
|
Reference in New Issue
Block a user