2.9
[glibc/nacl-glibc.git] / sysdeps / mach / hurd / powerpc / exc2signal.c
blob7cea85daa0fd0acefd8b0cf72100b62d82f46eba
1 /* Translate Mach exception codes into signal numbers. PowerPC version.
2 Copyright (C) 1991,92,94,96,97,2001 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 /* XXX there has got to be something more here */
50 case EXC_BAD_INSTRUCTION:
51 *signo = SIGILL;
52 detail->code = 0;
53 break;
55 case EXC_ARITHMETIC:
56 *signo = SIGFPE;
57 detail->code = 0;
58 break;
60 case EXC_EMULATION:
61 *signo = SIGEMT;
62 detail->code = 0;
63 break;
65 case EXC_SOFTWARE:
66 *signo = SIGEMT;
67 detail->code = 0;
68 break;
70 case EXC_BREAKPOINT:
71 *signo = SIGTRAP;
72 detail->code = 0;