Back to index

glibc  2.9
exc2signal.c
Go to the documentation of this file.
00001 /* Translate Mach exception codes into signal numbers.  MIPS version.
00002    Copyright (C) 1996, 1997 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <hurd.h>
00021 #include <hurd/signal.h>
00022 #include <mach/exception.h>
00023 
00024 /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
00025    into a signal number and signal subcode.  */
00026 
00027 void
00028 _hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
00029 {
00030   detail->error = 0;
00031 
00032   switch (detail->exc)
00033     {
00034     default:
00035       *signo = SIGIOT;
00036       detail->code = detail->exc;
00037       break;
00038       
00039     case EXC_BAD_ACCESS:
00040       if (detail->exc_code == KERN_PROTECTION_FAILURE)
00041        *signo = SIGSEGV;
00042       else
00043        *signo = SIGBUS;
00044       detail->code = detail->exc_subcode;
00045       detail->error = detail->exc_code;
00046       break;
00047 
00048     case EXC_BAD_INSTRUCTION:
00049       *signo = SIGILL;
00050       if (detail->exc_code == EXC_MIPS_II)
00051        detail->code = detail->exc_subcode;
00052       else
00053        detail->code = 0;
00054       break;
00055       
00056     case EXC_ARITHMETIC:
00057       switch (detail->exc_code)
00058        {
00059        case EXC_MIPS_OV:    /* integer overflow */
00060          *signo = SIGFPE;
00061          detail->code = detail->exc_subcode;
00062          break;
00063 
00064        default:
00065          *signo = SIGFPE;
00066          detail->code = 0;
00067          break;
00068 
00069        case EXC_MIPS_INT:
00070          /* Subcode is the fp_status word saved by the hardware.
00071             Give an error code corresponding to the first bit set.  */
00072          if (detail->exc_subcode == EXC_MIPS_FLT_UNIMP)
00073            *signo = SIGILL;
00074          else
00075            *signo = SIGFPE;
00076          detail->code = detail->exc_subcode;
00077          break;
00078        }
00079       break;
00080 
00081     case EXC_EMULATION:            
00082       /* 3.0 doesn't give this one, why, I don't know.  */
00083       *signo = SIGEMT;
00084       detail->code = 0;
00085       break;
00086 
00087     case EXC_SOFTWARE:
00088       *signo = SIGEMT;
00089       detail->code = 0;
00090       break;
00091       
00092     case EXC_BREAKPOINT:
00093       *signo = SIGTRAP;
00094       detail->code = 0;
00095       break;
00096     }
00097 }