improve ˆC handling (still needs work).
This commit is contained in:
parent
45baf800dd
commit
0f10f4332e
@ -3034,14 +3034,6 @@ Yap_absmi(int inp)
|
||||
if (LOCAL_PrologMode & (AbortMode|InterruptMode)) {
|
||||
CreepFlag = CalculateStackGap();
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
/* same instruction */
|
||||
if (LOCAL_PrologMode & InterruptMode) {
|
||||
LOCAL_PrologMode &= ~InterruptMode;
|
||||
SET_ASP(YREG, E_CB*sizeof(CELL));
|
||||
saveregs();
|
||||
Yap_ProcessSIGINT();
|
||||
setregs();
|
||||
}
|
||||
JMPNext();
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
|
22
C/grow.c
22
C/grow.c
@ -74,18 +74,6 @@ LeaveGrowMode(prolog_exec_mode grow_mode)
|
||||
{
|
||||
CACHE_REGS
|
||||
LOCAL_PrologMode &= ~grow_mode;
|
||||
if (LOCAL_PrologMode & AbortMode) {
|
||||
CACHE_REGS
|
||||
LOCAL_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
|
||||
Yap_RestartYap( 1 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -822,10 +810,10 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
}
|
||||
ASP -= 256;
|
||||
YAPEnterCriticalSection();
|
||||
LOCAL_TrDiff = LOCAL_LDiff = LOCAL_GDiff = LOCAL_GDiff0 = LOCAL_DelayDiff = LOCAL_BaseDiff = size;
|
||||
LOCAL_XDiff = LOCAL_HDiff = 0;
|
||||
LOCAL_GSplit = NULL;
|
||||
YAPEnterCriticalSection();
|
||||
SetHeapRegs(FALSE PASS_REGS);
|
||||
MoveLocalAndTrail( PASS_REGS1 );
|
||||
if (fix_code) {
|
||||
@ -849,10 +837,10 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
|
||||
AdjustStacksAndTrail(0, FALSE PASS_REGS);
|
||||
}
|
||||
AdjustRegs(MaxTemps PASS_REGS);
|
||||
YAPLeaveCriticalSection();
|
||||
ASP += 256;
|
||||
if (minimal_request)
|
||||
Yap_AllocHole(minimal_request, size);
|
||||
YAPLeaveCriticalSection();
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
LOCAL_total_heap_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
@ -1406,9 +1394,8 @@ growatomtable( USES_REGS1 )
|
||||
if (HeapTop + sizeof(YAP_SEG_SIZE) > HeapLim - MinHeapGap) {
|
||||
/* make sure there is no heap overflow */
|
||||
int res;
|
||||
YAPEnterCriticalSection();
|
||||
|
||||
res = do_growheap(FALSE, 0, NULL, NULL, NULL, NULL PASS_REGS);
|
||||
YAPLeaveCriticalSection();
|
||||
return res;
|
||||
} else {
|
||||
return TRUE;
|
||||
@ -1744,7 +1731,9 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
|
||||
#if USE_SYSTEM_MALLOC
|
||||
execute_growstack(size, TRUE, in_parser, old_trp, tksp, vep PASS_REGS);
|
||||
#else
|
||||
YAPEnterCriticalSection();
|
||||
if (!Yap_ExtendWorkSpace(size)) {
|
||||
YAPLeaveCriticalSection();
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
if (contiguous_only) {
|
||||
/* I can't expand in this case */
|
||||
@ -1753,7 +1742,6 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
|
||||
}
|
||||
execute_growstack(size, TRUE, in_parser, old_trp, tksp, vep PASS_REGS);
|
||||
} else {
|
||||
YAPEnterCriticalSection();
|
||||
if (in_parser) {
|
||||
LOCAL_TrDiff = LOCAL_LDiff = LOCAL_GDiff = LOCAL_BaseDiff = LOCAL_DelayDiff = LOCAL_XDiff = LOCAL_HDiff = LOCAL_GDiff0 = 0;
|
||||
AdjustScannerStacks(tksp, vep PASS_REGS);
|
||||
|
@ -4148,8 +4148,9 @@ LeaveGCMode( USES_REGS1 )
|
||||
LOCAL_PrologMode &= ~GCMode;
|
||||
if (LOCAL_PrologMode & AbortMode) {
|
||||
LOCAL_PrologMode &= ~AbortMode;
|
||||
Yap_Error(PURE_ABORT, TermNil, "");
|
||||
P = FAILCODE;
|
||||
/* in case someone mangles the P register */
|
||||
Yap_Error(PURE_ABORT, TermNil, "abort from console");
|
||||
Yap_RestartYap( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
28
C/sysbits.c
28
C/sysbits.c
@ -1553,15 +1553,14 @@ void (*handler)(int);
|
||||
static int
|
||||
InteractSIGINT(int ch) {
|
||||
CACHE_REGS
|
||||
LOCAL_PrologMode |= AsyncIntMode;
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
/* abort computation */
|
||||
if (LOCAL_PrologMode & (GCMode|ConsoleGetcMode|GrowStackMode|GrowHeapMode)) {
|
||||
if (LOCAL_PrologMode & (GCMode|ConsoleGetcMode|CritMode)) {
|
||||
LOCAL_PrologMode |= AbortMode;
|
||||
return -1;
|
||||
} else {
|
||||
Yap_Error(PURE_ABORT, TermNil, "abort from console");
|
||||
/* in case someone mangles the P register */
|
||||
}
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
Yap_RestartYap( 1 );
|
||||
@ -1569,44 +1568,36 @@ InteractSIGINT(int ch) {
|
||||
case 'b':
|
||||
/* continue */
|
||||
Yap_signal (YAP_BREAK_SIGNAL);
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
return 1;
|
||||
case 'c':
|
||||
/* continue */
|
||||
return 1;
|
||||
case 'd':
|
||||
Yap_signal (YAP_DEBUG_SIGNAL);
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
/* enter debug mode */
|
||||
return 1;
|
||||
case 'e':
|
||||
/* exit */
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
Yap_exit(0);
|
||||
return -1;
|
||||
case 'g':
|
||||
/* exit */
|
||||
Yap_signal (YAP_STACK_DUMP_SIGNAL);
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
return -1;
|
||||
case 't':
|
||||
/* start tracing */
|
||||
Yap_signal (YAP_TRACE_SIGNAL);
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
return 1;
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
case 'T':
|
||||
toggle_low_level_trace();
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
return 1;
|
||||
#endif
|
||||
case 's':
|
||||
/* show some statistics */
|
||||
Yap_signal (YAP_STATISTICS_SIGNAL);
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
return 1;
|
||||
case EOF:
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
return(0);
|
||||
break;
|
||||
case 'h':
|
||||
@ -1617,7 +1608,6 @@ InteractSIGINT(int ch) {
|
||||
fprintf(GLOBAL_stderr, " a for abort\n c for continue\n d for debug\n");
|
||||
fprintf(GLOBAL_stderr, " e for exit\n g for stack dump\n s for statistics\n t for trace\n");
|
||||
fprintf(GLOBAL_stderr, " b for break\n");
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
@ -1631,19 +1621,15 @@ ProcessSIGINT(void)
|
||||
{
|
||||
int ch, out;
|
||||
|
||||
LOCAL_PrologMode |= AsyncIntMode;
|
||||
do {
|
||||
ch = Yap_GetCharForSIGINT();
|
||||
} while (!(out = InteractSIGINT(ch)));
|
||||
LOCAL_PrologMode &= ~AsyncIntMode;
|
||||
LOCAL_PrologMode &= ~InterruptMode;
|
||||
return(out);
|
||||
}
|
||||
|
||||
int
|
||||
Yap_ProcessSIGINT(void)
|
||||
{
|
||||
return ProcessSIGINT();
|
||||
}
|
||||
|
||||
|
||||
#if !_MSC_VER && !defined(__MINGW32__)
|
||||
|
||||
#if HAVE_SIGNAL
|
||||
@ -1662,6 +1648,7 @@ HandleSIGINT (int sig)
|
||||
#endif
|
||||
{
|
||||
CACHE_REGS
|
||||
/* fprintf(stderr,"mode = %x\n",LOCAL_PrologMode); */
|
||||
my_signal(SIGINT, HandleSIGINT);
|
||||
/* do this before we act */
|
||||
#if HAVE_ISATTY
|
||||
@ -1673,8 +1660,9 @@ HandleSIGINT (int sig)
|
||||
if (LOCAL_InterruptsDisabled) {
|
||||
return;
|
||||
}
|
||||
if (LOCAL_PrologMode & (CritMode|ConsoleGetcMode)) {
|
||||
if (LOCAL_PrologMode & ConsoleGetcMode) {
|
||||
LOCAL_PrologMode |= InterruptMode;
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_SETBUF
|
||||
/* make sure we are not waiting for the end of line */
|
||||
|
15
H/Yap.h
15
H/Yap.h
@ -615,10 +615,6 @@ typedef enum
|
||||
LOCAL_CritLocks--; \
|
||||
if (!LOCAL_CritLocks) { \
|
||||
LOCAL_PrologMode &= ~CritMode; \
|
||||
if (LOCAL_PrologMode & InterruptMode) { \
|
||||
LOCAL_PrologMode &= ~InterruptMode; \
|
||||
Yap_ProcessSIGINT(); \
|
||||
} \
|
||||
if (LOCAL_PrologMode & AbortMode) { \
|
||||
LOCAL_PrologMode &= ~AbortMode; \
|
||||
Yap_Error(PURE_ABORT, 0, ""); \
|
||||
@ -636,13 +632,10 @@ typedef enum
|
||||
#define YAPLeaveCriticalSection() \
|
||||
{ \
|
||||
LOCAL_PrologMode &= ~CritMode; \
|
||||
if (LOCAL_PrologMode & InterruptMode) { \
|
||||
LOCAL_PrologMode &= ~InterruptMode; \
|
||||
Yap_ProcessSIGINT(); \
|
||||
} \
|
||||
if (LOCAL_PrologMode & AbortMode) { \
|
||||
LOCAL_PrologMode &= ~AbortMode; \
|
||||
Yap_Error(PURE_ABORT, 0, ""); \
|
||||
Yap_RestartYap( 1 ); \
|
||||
} \
|
||||
/* UNLOCK(BGL); */ \
|
||||
}
|
||||
@ -657,13 +650,9 @@ typedef enum
|
||||
LOCAL_CritLocks--; \
|
||||
if (!LOCAL_CritLocks) { \
|
||||
LOCAL_PrologMode &= ~CritMode; \
|
||||
if (LOCAL_PrologMode & InterruptMode) { \
|
||||
LOCAL_PrologMode &= ~InterruptMode; \
|
||||
Yap_ProcessSIGINT(); \
|
||||
} \
|
||||
if (LOCAL_PrologMode & AbortMode) { \
|
||||
LOCAL_PrologMode &= ~AbortMode; \
|
||||
Yap_Error(PURE_ABORT, 0, ""); \
|
||||
Yap_RestartYap( 1 ); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
@ -356,7 +356,6 @@ void STD_PROTO(Yap_InitSysbits,(void));
|
||||
void STD_PROTO(Yap_InitSysPreds,(void));
|
||||
void STD_PROTO(Yap_InitTime,(void));
|
||||
int STD_PROTO(Yap_TrueFileName, (char *, char *, int));
|
||||
int STD_PROTO(Yap_ProcessSIGINT,(void));
|
||||
double STD_PROTO(Yap_random, (void));
|
||||
#ifdef _WIN32
|
||||
char *STD_PROTO(Yap_RegistryGetString,(char *));
|
||||
|
Reference in New Issue
Block a user