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

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

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

revision 525 by johnpye, Fri Apr 21 07:22:20 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
  *  By Benjamin Andrew Allan  
  *  Version: $Revision: 1.6 $  
  *  Version control file: $RCSfile: ascSignal.h,v $  
  *  Date last modified: $Date: 1998/01/10 18:00:05 $  
  *  Last modified by: $Author: ballan $  
  *  
  *  This file is part of the Ascend Programming System.  
  *  This file standardizes the handling of signals because some OS  
  *  reset signals to SIG_DFL when a trap goes off while others  
  *  process the signal but leave the trapping function in place.  
  *  We want the second behavior and this gives it to us.  
  *  
  *  Copyright (C) 1997 Benjamin Andrew Allan  
  *  
  *  The Ascend Programming System 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 of the  
  *  License, or (at your option) any later version.  
  *  
  *  ASCEND is distributed in hope that it will be  
  *  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.  
  */  
4    
5  /** @file      This program is free software; you can redistribute it and/or modify
6   *  Signal handling protocol definitions for ASCEND.      it under the terms of the GNU General Public License as published by
7   *      the Free Software Foundation; either version 2, or (at your option)
8   *  This module implements limited support for managing signal handlers.      any later version.
9   *  This includes:  
10   *    - a standard signal handler - Asc_SignalTrap()      This program is distributed in the hope that it will be useful,
11   *    - global jmp_buf's for use with Asc_SignalTrap()      but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *    - functions for managing nested signal handlers      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *      GNU General Public License for more details.
14   *  The following signal types are currently supported:  
15   *    - SIGFPE  - floating point exception      You should have received a copy of the GNU General Public License
16   *    - SIGINT  - CTRL-C interactive attention request      along with this program; if not, write to the Free Software
17   *    - SIGSEGV - segmentation fault      Foundation, Inc., 59 Temple Place - Suite 330,
18   *      Boston, MA 02111-1307, USA.
19   *  A simple use of these facilities to trap floating point exceptions  *//**
20   *  might be as follows:      @file
21   *  <pre>      Signal handling protocol definitions for ASCEND.
22   *     Asc_SignalInit();  
23   *     Asc_SignalHandlerPush(SIGFPE, Asc_SignalTrap);      This file standardizes the handling of signals because some OS
24   *     if (setjmp(g_fpe_env)==0) {      reset signals to SIG_DFL when a trap goes off while others
25   *       y = sqrt(x);      process the signal but leave the trapping function in place.
26   *     } else {      We want the second behavior and this gives it to us.
27   *       y = sqrt(-x);  
28   *     }      This module implements limited support for managing signal handlers.
29   *     Asc_SignHandlerPop(SIGFPE,Asc_SignalTrap);      This includes:
30   *     Asc_SignalDestroy();        - a standard signal handler - Asc_SignalTrap()
31   *  </pre>        - global jmp_buf's for use with Asc_SignalTrap()
32          - functions for managing nested signal handlers
33        
34        The following signal types are currently supported:
35          - SIGFPE  - floating point exception
36          - SIGINT  - CTRL-C interactive attention request
37          - SIGSEGV - segmentation fault
38        
39        A simple use of these facilities to trap floating point exceptions
40        might be as follows:
41        <pre>
42           Asc_SignalInit();
43           Asc_SignalHandlerPush(SIGFPE, Asc_SignalTrap);
44           if (setjmp(g_fpe_env)==0) {
45             y = sqrt(x);
46           } else {
47             y = sqrt(-x);
48           }
49           Asc_SignHandlerPop(SIGFPE,Asc_SignalTrap);
50           Asc_SignalDestroy();
51        </pre>
52   *  This example uses the built-in signal handler Asc_SignalTrap()   *  This example uses the built-in signal handler Asc_SignalTrap()
53   *  and the global <code>jmp_buf</code> g_fpe_env.  After initializing   *  and the global <code>jmp_buf</code> g_fpe_env.  After initializing
54   *  the signal manager and registering the handler, <code>setjmp</code>   *  the signal manager and registering the handler, <code>setjmp</code>
# Line 100  Line 91 
91   *  to be lost or to corrupt the managed handlers.<br><br>   *  to be lost or to corrupt the managed handlers.<br><br>
92   *   *
93   *  Another warning: setjmp is expensive if called inside a fast loop.   *  Another warning: setjmp is expensive if called inside a fast loop.
94   *  <pre>  
95   *  Requires:     #include "utilities/ascConfig.h"      Requires:
96   *  </pre>      #include "utilities/ascConfig.h"
97   */  *//*
98        Signal handling protocol definitions for ASCEND
99        May 27, 1997
100        By Benjamin Andrew Allan
101        Version: $Revision: 1.6 $
102        Version control file: $RCSfile: ascSignal.h,v $
103        Date last modified: $Date: 1998/01/10 18:00:05 $
104        Last modified by: $Author: ballan $
105    */
106    
107  #ifndef ASC_ASCSIGNAL_H  #ifndef ASC_ASCSIGNAL_H
108  #define ASC_ASCSIGNAL_H  #define ASC_ASCSIGNAL_H

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

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