2.9
[glibc/nacl-glibc.git] / sysdeps / mach / hurd / alpha / exc2signal.c
blob5f3fbbbbb193debedbc85d8da08087afc46ac89c
1 /* Translate Mach exception codes into signal numbers. Alpha version.
2 Copyright (C) 1994,97,2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <hurd.h>
21 #include <hurd/signal.h>
22 #include <mach/exception.h>
24 /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
25 into a signal number and signal subcode. */
27 void
28 _hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
30 detail->error = 0;
32 switch (detail->exc)
34 default:
35 *signo = SIGIOT;
36 detail->code = detail->exc;
37 break;
39 case EXC_BAD_ACCESS:
40 if (detail->exc_code == KERN_PROTECTION_FAILURE)
41 *signo = SIGSEGV;
42 else
43 *signo = SIGBUS;
44 detail->code = detail->exc_subcode;
45 detail->error = detail->exc_code;
46 break;
48 case EXC_BAD_INSTRUCTION:
49 *signo = SIGILL;
50 detail->code = detail->exc_code;
51 break;
53 case EXC_ARITHMETIC:
54 *signo = SIGFPE;
55 detail->code = detail->exc_code;
56 break;
57 break;
59 case EXC_EMULATION:
60 /* 3.0 doesn't give this one, why, I don't know. */
61 *signo = SIGEMT;
62 detail->code = detail->exc_code;
63 break;
65 case EXC_SOFTWARE:
66 *signo = SIGEMT;
67 detail->code = detail->exc_code;
68 break;
70 case EXC_BREAKPOINT:
71 *signo = SIGTRAP;
72 detail->code = detail->exc_code;
73 break;