/[ascend]/trunk/base/generic/utilities/ascSignal.c
ViewVC logotype

Diff of /trunk/base/generic/utilities/ascSignal.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 525 by johnpye, Fri Mar 31 08:52:57 2006 UTC revision 526 by johnpye, Fri Apr 21 13:47:31 2006 UTC
# Line 1  Line 1 
1  /*  /*  ASCEND modelling environment
2   *  Signal handling protocol definitions for ASCEND      Copyright (C) 1997 Benjamin Andrew Allan
3   *  May 27, 1997      Copyright (C) 2006 Carnegie Mellon University
4   *  By Benjamin Andrew Allan  
5   *  Version: $Revision: 1.9 $      This program is free software; you can redistribute it and/or modify
6   *  Version control file: $RCSfile: ascSignal.c,v $      it under the terms of the GNU General Public License as published by
7   *  Date last modified: $Date: 1999/01/19 12:23:20 $      the Free Software Foundation; either version 2, or (at your option)
8   *  Last modified by: $Author: mthomas $      any later version.
9   *  Part of Ascend  
10   *      This program is distributed in the hope that it will be useful,
11   *  This file is part of the Ascend Programming System.      but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  Copyright (C) 1997 Benjamin Andrew Allan      GNU General Public License for more details.
14   *  
15   *  The Ascend Programming System is free software; you can redistribute      You should have received a copy of the GNU General Public License
16   *  it and/or modify it under the terms of the GNU General Public License as      along with this program; if not, write to the Free Software
17   *  published by the Free Software Foundation; either version 2 of the      Foundation, Inc., 59 Temple Place - Suite 330,
18   *  License, or (at your option) any later version.      Boston, MA 02111-1307, USA.
19   *  *//**
20   *  ASCEND is distributed in hope that it will be   * Signal handling protocol definitions for ASCEND
  *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of  
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  
  *  General Public License for more details.  
  *  
  *  You should have received a copy of the GNU General Public License  
  *  along with the program; if not, write to the Free Software Foundation,  
  *  Inc., 675 Mass Ave, Cambridge, MA 02139 USA.  Check the file named  
  *  COPYING.  
  *  
  */  
 /*  
21   * Start of making signal handling in ASCEND   * Start of making signal handling in ASCEND
22   * code somewhat sane. Still needs to somehow   * code somewhat sane. Still needs to somehow
23   * support the management of jmp_buf's so that   * support the management of jmp_buf's so that
# Line 37  Line 26 
26   * A better alternative is to make all our code check/return   * A better alternative is to make all our code check/return
27   * status flags based on a variable set by the trap   * status flags based on a variable set by the trap
28   * and cleared by recipient.   * and cleared by recipient.
29   */  *//*
30  /*   *  May 27, 1997
31     *  By Benjamin Andrew Allan
32     *  Version: $Revision: 1.9 $
33     *  Version control file: $RCSfile: ascSignal.c,v $
34     *  Date last modified: $Date: 1999/01/19 12:23:20 $
35     *  Last modified by: $Author: mthomas $
36     *
37   *  ChangeLog   *  ChangeLog
38   *   *
39   *  10/15/2005  - Changed ascresetneeded() so that any previously   *  10/15/2005  - Changed ascresetneeded() so that any previously
# Line 98  static int f_seg_top_of_stack = -1; Line 93  static int f_seg_top_of_stack = -1;
93    
94  #ifndef NO_SIGSEGV_TRAP  #ifndef NO_SIGSEGV_TRAP
95  /* function to throw an interrupt. system dependent. */  /* function to throw an interrupt. system dependent. */
96  static int testdooley2(int sig)  static int testdooley2(int sig){
 {  
97    raise(sig);    raise(sig);
98    return 0;    return 0;
99  }  }
100  #endif  #endif
101    
102  #ifndef NO_SIGINT_TRAP  #if !defined(NO_SIGINT_TRAP) || !defined(NO_SIGSEGV_TRAP)
103  /* function to catch an interrupt */  /* function to catch an interrupt */
104  static void testctrlc(int signum)  static void testcatch(int signum){
 {  
105    FPRINTF(ASCERR," signal %d caught ",signum);    FPRINTF(ASCERR," signal %d caught ",signum);
106    if (signum == SIGFPE) {    if (signum == SIGFPE) {
107      FPRESET;      FPRESET;
# Line 153  static int ascresetneeded(void) { Line 146  static int ascresetneeded(void) {
146  #ifndef NO_SIGINT_TRAP  #ifndef NO_SIGINT_TRAP
147    
148    /* test interrupt */    /* test interrupt */
149    savedtrap = signal(SIGINT, testctrlc);    savedtrap = signal(SIGINT, testcatch);
150    CONSOLE_DEBUG("Testing signal SIGINT (signum = %d) %p\t%p\t", SIGINT, savedtrap, testctrlc);    CONSOLE_DEBUG("Testing signal SIGINT (signum = %d) %p\t%p\t", SIGINT, savedtrap, testcatch);
151    if (setjmp(f_test_env) == 0) {    if (setjmp(f_test_env) == 0) {
152      testdooley2(SIGINT);      testdooley2(SIGINT);
153    } else {    } else {
# Line 167  static int ascresetneeded(void) { Line 160  static int ascresetneeded(void) {
160    }    }
161    lasttrap = signal(SIGINT, (NULL != savedtrap) ? savedtrap : SIG_DFL);    lasttrap = signal(SIGINT, (NULL != savedtrap) ? savedtrap : SIG_DFL);
162    CONSOLE_DEBUG("%p",lasttrap);    CONSOLE_DEBUG("%p",lasttrap);
163    if (lasttrap != testctrlc) {    if (lasttrap != testcatch) {
164      result = 1;      result = 1;
165    }    }
166    
# Line 182  static int ascresetneeded(void) { Line 175  static int ascresetneeded(void) {
175    
176  #ifndef NO_SIGSEGV_TRAP  #ifndef NO_SIGSEGV_TRAP
177    /* passed interrupt, check fpe */    /* passed interrupt, check fpe */
178    savedtrap=signal(SIGFPE, testctrlc);    savedtrap=signal(SIGFPE, testcatch);
179    CONSOLE_DEBUG("Testing signal %d %p\t%p\t",SIGFPE, savedtrap, testctrlc);    CONSOLE_DEBUG("Testing signal %d %p\t%p\t",SIGFPE, savedtrap, testcatch);
180    if (setjmp(f_test_env)==0) {    if (setjmp(f_test_env)==0) {
181      testdooley2(SIGFPE);      testdooley2(SIGFPE);
182    } else {    } else {
# Line 196  static int ascresetneeded(void) { Line 189  static int ascresetneeded(void) {
189    }    }
190    lasttrap = signal(SIGFPE, (NULL != savedtrap) ? savedtrap : SIG_DFL);    lasttrap = signal(SIGFPE, (NULL != savedtrap) ? savedtrap : SIG_DFL);
191    CONSOLE_DEBUG("%p\n",lasttrap);    CONSOLE_DEBUG("%p\n",lasttrap);
192    if (lasttrap != testctrlc) {    if (lasttrap != testcatch) {
193      result = 1;      result = 1;
194    }    }
195  #else  #else

Legend:
Removed from v.525  
changed lines
  Added in v.526

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22