--- gforth/engine/signals.c 2006/10/21 19:22:03 1.30 +++ gforth/engine/signals.c 2011/12/31 15:29:26 1.42 @@ -1,12 +1,12 @@ /* signal handling - Copyright (C) 1995,1996,1997,1998,2000,2003 Free Software Foundation, Inc. + Copyright (C) 1995,1996,1997,1998,2000,2003,2006,2007,2011 Free Software Foundation, Inc. This file is part of Gforth. Gforth is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 + as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + along with this program; if not, see http://www.gnu.org/licenses/. */ @@ -30,9 +29,9 @@ #if !defined(apollo) && !defined(MSDOS) #include #endif -/* #include */ #include #include +#include #include "io.h" #ifndef HAVE_STACK_T @@ -41,7 +40,7 @@ typedef struct sigaltstack stack_t; #endif #define DEFAULTCOLS 80 -#if defined(MSDOS) || defined (_WIN32) +#if defined(MSDOS) || defined (_WIN32) || defined (__CYGWIN__) #define DEFAULTROWS 25 #else #define DEFAULTROWS 24 @@ -95,6 +94,11 @@ graceful_exit (int sig) jmp_buf throw_jmp_buf; +void throw(int code) +{ + longjmp(throw_jmp_buf,code); /* !! or use siglongjmp ? */ +} + static void signal_throw(int sig) { @@ -120,7 +124,7 @@ signal_throw(int sig) sigprocmask(SIG_SETMASK, &emptyset, NULL); } #endif - longjmp(throw_jmp_buf,code); /* !! or use siglongjmp ? */ + throw(code); } #ifdef SA_SIGINFO @@ -137,10 +141,10 @@ static void fpe_handler(int sig, siginfo switch(info->si_code) { #ifdef FPE_INTDIV - case FPE_INTDIV: code=-10; break; /* integer divide by zero */ + case FPE_INTDIV: code=BALL_DIVZERO; break; #endif #ifdef FPE_INTOVF - case FPE_INTOVF: code=-11; break; /* integer overflow */ + case FPE_INTOVF: code=BALL_RESULTRANGE; break; /* integer overflow */ #endif #ifdef FPE_FLTDIV case FPE_FLTDIV: code=-42; break; /* floating point divide by zero */ @@ -160,7 +164,7 @@ static void fpe_handler(int sig, siginfo #endif default: code=-55; break; } - longjmp(throw_jmp_buf,code); + throw(code); } @@ -193,7 +197,7 @@ static void segv_handler(int sig, siginf code=-44; else if (JUSTOVER(addr, NEXTPAGE(h->fp_stack_base+h->fp_stack_size))) code=-45; - longjmp(throw_jmp_buf,code); + throw(code); } #endif /* defined(SA_SIGINFO) */ @@ -227,7 +231,7 @@ void get_winsize() #endif if (rows==0) rows=DEFAULTROWS; - if (rows==0) + if (cols==0) cols=DEFAULTCOLS; } @@ -410,9 +414,11 @@ void install_signal_handlers(void) sigstack.ss_flags=0; sas_retval=sigaltstack(&sigstack,(stack_t *)0); } +#if defined(HAS_FILE) || !defined(STANDALONE) if (debug) fprintf(stderr,"sigaltstack: %s\n",strerror(sas_retval)); #endif +#endif #define DIM(X) (sizeof (X) / sizeof *(X)) /*