void fussy( void ) { befussy = 1; while( befussy ) { if( sp > stack + STACK_DIM ) { put_c_string( "Stack underflow!\n" ); interrupt( 1 ); } if( sp < stack ) { put_c_string( "Stack overflow!\n" ); interrupt( 1 ); } if( rsp > rstack + RSTACK_DIM ) { put_c_string( "Return stack underflow!\n" ); interrupt( 1 ); } if( rsp < rstack ) { put_c_string( "Return stack overflow!\n" ); interrupt( 1 ); } (*(prim *)(intptr_t)*(cell *)(intptr_t)(*++lc))(); } }
void xeq( void ) { cell * volatile savedlc = ((cell *) (intptr_t) *(lc+1)) + D_BODY - 1; int sig; sig = setjmp( rexeq ); switch( sig ) { /* here's where to have different actions for different aborts */ case 0 : /* first time through */ break; case 1 : put_c_string( "\nSoftware abort\n" ); break; case 2 : put_c_string( "\nUndefined instruction\n" ); break; case 3 : put_c_string( "\nSoftware interrupt\n" ); break; case 4 : put_c_string( "\nMemory access error\n" ); break; case 6 : put_c_string( "\nUncaught IRQ\n" ); break; case 7 : put_c_string( "\nUncaught FIQ\n" ); break; case 8 : put_c_string( "\nInterrupted\n" ); break; default: put_c_string( "\nUnknown condition\n" ); break; } if( sig ) primitive_io_abort(); /* reset input after restart */ sp = stack + STACK_DIM; rsp = rstack + RSTACK_DIM; lc = savedlc; fussy(); /* returns if fast interpreter requested */ interpreter(); /* Never returns */ }
void setup_memory( void ) { cell free; extern cell end; sp = stack + STACK_DIM; rsp = rstack + RSTACK_DIM; // deflast = 0; // constlast = 0; cbuf = (cell) compile_buf; /* hack to estimate free mem, allocate to dictionaries */ free = &free - &end - RESERVE; deftop = sbrk( sizeof(cell) * (&free - &end - RESERVE )); if( deftop == (void *) -1 ) { put_c_string( "\nDictionary memory allocation failed!\n" ); for(;;); } defend = constop = deftop + free/2; constend = deftop + free; }
/*-------------------------------------------------------------------------*/ static int my_sqlite3_authorizer (void * data, int what, const char* arg1, const char* arg2, const char* dbname, const char* view) /* Callback function for SQLite to handle authorizations. */ { struct error_recovery_info error_recovery_info; svalue_t *save_sp, sarg1, sarg2; struct control_stack *save_csp; int val; switch(what) { case SQLITE_PRAGMA: /* PRAGMA name [ = value ] * PRAGMA function(arg) * * arg1: name/function * arg2: value/arg * dbname/view: NULL */ error_recovery_info.rt.last = rt_context; error_recovery_info.rt.type = ERROR_RECOVERY_APPLY; rt_context = (rt_context_t *)&error_recovery_info; save_sp = inter_sp; save_csp = csp; sarg1.type = T_INVALID; sarg2.type = T_INVALID; if (setjmp(error_recovery_info.con.text)) { secure_apply_error(save_sp, save_csp, MY_FALSE); val = SQLITE_DENY; } else { if(arg1) put_c_string(&sarg1, arg1); else put_number(&sarg1, 0); if(arg2) put_c_string(&sarg2, arg2); else put_number(&sarg2, 0); if(privilege_violation2(STR_SQLITE_PRAGMA, &sarg1, &sarg2, inter_sp)) val = SQLITE_OK; else val = SQLITE_DENY; } free_svalue(&sarg1); sarg1.type = T_INVALID; free_svalue(&sarg2); sarg2.type = T_INVALID; rt_context = error_recovery_info.rt.last; return val; case SQLITE_ATTACH: /* ATTACH "filename" AS "dbname" * * arg1: filename * arg2, dbname, view: NULL */ /* SQLite3 doesn't allow the filename to be changed, * but at least we must convert an absolute pathname * to a relative one. So we have to deactivate it... */ return SQLITE_DENY; default: return SQLITE_OK; } } /* my_sqlite3_authorizer() */
void space( void ) { put_c_string( " " ); }
void nl( void ) { put_c_string( "\n" ); }
void putf( void ) { char buf[100]; (void) snprintf( buf, 100, "%g", (double) *(fcell*)sp++ ); put_c_string( buf );}
void putx( void ) { char buf[16]; (void) snprintf( buf, 16, "%x", (unsigned)*sp++); put_c_string( buf );}
void putd( void ) { char buf[16]; (void) snprintf( buf, 16, "%d", (int)*sp++); put_c_string( buf );}
void put_hex( unsigned x ) { char buf[16]; (void) snprintf( buf, 16, "%x", x); put_c_string( buf );}