delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/14/11:08:04

Message-Id: <3.0.6.32.19990214110623.008d6bb0@pop.netaddress.com>
X-Sender: pderbysh AT pop DOT netaddress DOT com
X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32)
Date: Sun, 14 Feb 1999 11:06:23 -0500
To: djgpp AT delorie DOT com
From: Paul Derbyshire <pderbysh AT usa DOT net>
Subject: Re: Exception handling
In-Reply-To: <Pine.UW2.3.95.990214104139.24547A-100000@bryggen.bgnett.no
>
References: <36C657F1 DOT 50F398A8 AT cartsys DOT com>
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

At 10:53 AM 2/14/99 +0100, you wrote:
>static void ExcHandler (int sig)
>{
>  static int been_here = 0;
>  static jmp_buf exc_buf;
>  int    i;
> 
>  if (been_here)
>  {
>    been_here = 0;
>    signal (sig,SIG_DFL);
>    __djgpp_exception_state_ptr = &exc_buf;
>  }
>  else
>  {
>    memcpy (&exc_buf,__djgpp_exception_state_ptr,sizeof(exc_buf));
>    been_here = 1;
> 
>    if (sig == SIGFPE)
>    {
>      _clear87();
>      _fpreset();
>    }
>    psignal (sig, "shutdown");
>    
>    .. do your main exc-processing here..
>  } 
>  raise (SIGABRT);
>}

Clever. I like the been_here var to prevent endlessly looping on nested
signals.
-- 
   .*.  "Clouds are not spheres, mountains are not cones, coastlines are not
-()  <  circles, and bark is not smooth, nor does lightning travel in a
   `*'  straight line."    -------------------------------------------------
        -- B. Mandelbrot  |http://surf.to/pgd.net
_____________________ ____|________     Paul Derbyshire     pderbysh AT usa DOT net
Programmer & Humanist|ICQ: 10423848|

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019