Back to index

glibc  2.9
exc2signal.c
Go to the documentation of this file.
00001 /* Translate Mach exception codes into signal numbers.  PowerPC version.
00002    Copyright (C) 1991,92,94,96,97,2001 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       /* XXX there has got to be something more here */
00049 
00050     case EXC_BAD_INSTRUCTION:
00051       *signo = SIGILL;
00052       detail->code = 0;
00053       break;
00054 
00055     case EXC_ARITHMETIC:
00056       *signo = SIGFPE;
00057       detail->code = 0;
00058       break;
00059 
00060     case EXC_EMULATION:
00061       *signo = SIGEMT;
00062       detail->code = 0;
00063       break;
00064 
00065     case EXC_SOFTWARE:
00066       *signo = SIGEMT;
00067       detail->code = 0;
00068       break;
00069 
00070     case EXC_BREAKPOINT:
00071       *signo = SIGTRAP;
00072       detail->code = 0;
00073     }
00074 }