Back to index

glibc  2.9
exc2signal.c
Go to the documentation of this file.
00001 /* Translate Mach exception codes into signal numbers.  Stub version.
00002    Copyright (C) 1991, 1992, 1994, 1995, 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 
00022 /* This file must be modified with machine-dependent details.  */
00023 #error "need to write sysdeps/mach/hurd/MACHINE/exc2signal.c"
00024 
00025 /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
00026    into a signal number and signal subcode.  */
00027 
00028 void
00029 _hurd_exception2signal (int exception, int code, int subcode,
00030                      int *signo, int *sigcode, int *error)
00031 {
00032   *error = 0;
00033 
00034   switch (exception)
00035     {
00036     default:
00037       *signo = SIGIOT;
00038       *sigcode = exception;
00039       break;
00040 
00041     case EXC_BAD_ACCESS:
00042       if (code == KERN_PROTECTION_FAILURE)
00043        *signo = SIGSEGV;
00044       else
00045        *signo = SIGBUS;
00046       *sigcode = subcode;
00047       *error = code;
00048       break;
00049 
00050     case EXC_BAD_INSTRUCTION:
00051       *signo = SIGILL;
00052       *sigcode = 0;
00053       break;
00054 
00055     case EXC_ARITHMETIC:
00056       *signo = SIGFPE;
00057       *sigcode = 0;
00058       break;
00059 
00060     case EXC_EMULATION:
00061     case EXC_SOFTWARE:
00062       *signo = SIGEMT;
00063       *sigcode = 0;
00064       break;
00065 
00066     case EXC_BREAKPOINT:
00067       *signo = SIGTRAP;
00068       *sigcode = 0;
00069       break;
00070     }
00071 }