From: David S. W. <dw...@us...> - 2001-11-07 21:08:13
|
Update of /cvsroot/xsb/XSB/emu In directory usw-pr-cvs1:/tmp/cvs-serv5234 Modified Files: auxlry.h builtin.c call_xsb_i.h emudef.h init_xsb.c subp.c Log Message: I modified slightly the way interrupts are handled. There had been a couple of mechanisms, and I tried to consolidate them. I elimitaed call_intercept and merged it in with *asynint_ptr. Now the keyboard interrupt can be used for C-user-defined interrupts. There is a new variable asynint_code that can be set when an interrupt is signaled. It is set to 0 by the system signal catcher. To generate a user-defined interrupt, you need to set the KEYINT_MARK bit of *asynint_ptr and set asynint_code to your integer code. Then when this interrupt is fielded, it will call the keyboard interrupt handler (set by set_inthandler imported from loader) which is a two argument predicate. When it is called, the first argument will be the goal to call when continuing out of the interrupt; the second argument will be the value of asynint_code. Index: auxlry.h =================================================================== RCS file: /cvsroot/xsb/XSB/emu/auxlry.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- auxlry.h 1999/12/10 07:47:22 1.9 +++ auxlry.h 2001/11/07 21:08:00 1.10 @@ -40,7 +40,7 @@ extern struct trace_str tds; -extern byte call_intercept; /* hitrace or trace_sta for efficiency */ +extern int *asynint_ptr; #define local_global_exception(t_pcreg) \ t_pcreg = exception_handler("! Local/Global Stack Overflow Exception\n") Index: builtin.c =================================================================== RCS file: /cvsroot/xsb/XSB/emu/builtin.c,v retrieving revision 1.130 retrieving revision 1.131 diff -u -r1.130 -r1.131 --- builtin.c 2001/09/21 15:01:15 1.130 +++ builtin.c 2001/11/07 21:08:00 1.131 @@ -1105,8 +1105,9 @@ break; case STAT_SET_FLAG: /* R1: flagname(+int); R2: value(+int); */ flags[ptoc_int(1)] = ptoc_int(2); - call_intercept = (byte) (flags[DEBUG_ON]|flags[TRACE_STA] - |flags[HITRACE]|flags[CLAUSE_INT]); + if (flags[DEBUG_ON]||flags[TRACE_STA]||flags[HITRACE]||flags[CLAUSE_INT]) + *asynint_ptr |= MSGINT_MARK; + else *asynint_ptr &= ~MSGINT_MARK; break; case BUFF_ALLOC: { /* R1: size (+integer); R2: -buffer; */ /* the length of the buffer is also stored at position 0 */ Index: call_xsb_i.h =================================================================== RCS file: /cvsroot/xsb/XSB/emu/call_xsb_i.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- call_xsb_i.h 2000/05/25 23:37:25 1.2 +++ call_xsb_i.h 2001/11/07 21:08:00 1.3 @@ -74,7 +74,7 @@ break; *****/ } - if (call_intercept) intercept(psc); + if (*asynint_ptr) intercept(psc); return TRUE; } Index: emudef.h =================================================================== RCS file: /cvsroot/xsb/XSB/emu/emudef.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- emudef.h 2001/05/24 17:54:51 1.27 +++ emudef.h 2001/11/07 21:08:00 1.28 @@ -69,8 +69,6 @@ */ byte *inst_begin; -byte call_intercept = 0; /* hitrace or trace_sta for efficiency */ - char *nil_sym; Pair list_str; @@ -87,6 +85,7 @@ char *list_dot; +int asynint_code = 0; int asynint_val = 0; int *asynint_ptr = &asynint_val; @@ -234,32 +233,26 @@ #define call_sub(PSC) { \ - if ( (*asynint_ptr > 0) | call_intercept \ - | int_val(cell(interrupt_reg)) ) { \ - if (*asynint_ptr > 0) { /* non-attv interrupt detected */ \ - if (*asynint_ptr == KEYINT_MARK) { \ + if ( (*asynint_ptr) | int_val(cell(interrupt_reg)) ) { \ + if (*asynint_ptr) { /* non-attv intrpt */ \ + if (*asynint_ptr & KEYINT_MARK) { \ synint_proc(PSC, MYSIG_KEYB, lpcreg-2*sizeof(Cell)); \ lpcreg = pcreg; \ } \ else \ lpcreg = (byte *)get_ep(PSC); \ - *asynint_ptr = 0; \ + *asynint_ptr = *asynint_ptr & ~KEYINT_MARK; \ + asynint_code = 0; \ } \ - else if (int_val(cell(interrupt_reg))) { \ - /* there is attv interrupt */ \ + else if (int_val(cell(interrupt_reg))) { /* attv intrpt */ \ synint_proc(PSC, MYSIG_ATTV, lpcreg-2*sizeof(Cell)); \ lpcreg = pcreg; \ /* Set PSC to '_$attv_int'/2, so that the later call of */ \ /* intercept(PSC) will set the return point, pcreg, to */ \ /* '_$attv_int'/2. */ \ PSC = (Psc) flags[MYSIG_ATTV+INT_HANDLERS_FLAGS_START]; \ - } \ - else { \ - lpcreg = (pb)get_ep(PSC); \ - /* check_glstack_overflow(get_arity(PSC), */ \ - /* lpcreg,OVERFLOW_MARGIN); */ \ } \ - if (call_intercept) { /* for debugging or for statistics */ \ + if (*asynint_ptr & MSGINT_MARK) { /* for debug or for stats */ \ pcreg = lpcreg; \ intercept(PSC); \ lpcreg = pcreg; \ Index: init_xsb.c =================================================================== RCS file: /cvsroot/xsb/XSB/emu/init_xsb.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- init_xsb.c 2001/07/16 05:15:37 1.18 +++ init_xsb.c 2001/11/07 21:08:01 1.19 @@ -61,6 +61,7 @@ #include "export.h" #include "io_builtins_xsb.h" #include "timer_defs_xsb.h" +#include "sig_xsb.h" /*-----------------------------------------------------------------------*/ @@ -411,7 +412,7 @@ break; case 's': flags[TRACE_STA] = 1; - call_intercept = 1; + *asynint_ptr |= MSGINT_MARK; break; case 'S': flags[TABLING_METHOD] = SUBSUMPTIVE_TEM; @@ -423,13 +424,13 @@ break; case 'T': flags[HITRACE] = 1; - call_intercept = 1; + *asynint_ptr |= MSGINT_MARK; break; case 't': #ifdef DEBUG flags[PIL_TRACE] = 1; flags[HITRACE] = 1; - call_intercept = 1; + *asynint_ptr |= MSGINT_MARK; #else xsb_exit("-t option unavailable for this executable (non-debug mode)"); #endif Index: subp.c =================================================================== RCS file: /cvsroot/xsb/XSB/emu/subp.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- subp.c 2001/11/02 22:20:53 1.55 +++ subp.c 2001/11/07 21:08:01 1.56 @@ -81,6 +81,7 @@ double realtime_count; extern int *asynint_ptr; /* 0 - no interrupt (or being processed) */ +extern int asynint_code; /* 0 means keyboard interrupt */ extern void dis(xsbBool), debug_call(Psc); extern void total_stat(double); @@ -319,10 +320,9 @@ case MYSIG_SPY: /* 3 */ case MYSIG_TRACE: /* 4 */ case MYSIG_CLAUSE: /* 16 */ - if (psc) - bld_cs(reg+1, build_call(psc)); + if (psc) bld_cs(reg+1, build_call(psc)); psc = (Psc)flags[intcode+INT_HANDLERS_FLAGS_START]; - bld_int(reg+2, intcode); + bld_int(reg+2, asynint_code); pcreg = get_ep(psc); break; case MYSIG_ATTV: /* 8 */ @@ -353,10 +353,11 @@ #ifndef LINUX init_interrupt(); /* reset interrupt, if using signal */ #endif - if ((*asynint_ptr & KEYINT_MARK) != 0) { + if (*asynint_ptr & KEYINT_MARK) { xsb_abort("unhandled keyboard interrupt"); } else { *asynint_ptr |= KEYINT_MARK; + asynint_code = 0; } } |