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