]>
Commit | Line | Data |
---|---|---|
a334319f UD |
1 | /* Translate Mach exception codes into signal numbers. MIPS version. |
2 | Copyright (C) 1996, 1997 Free Software Foundation, Inc. | |
478b92f0 | 3 | This file is part of the GNU C Library. |
28f540f4 | 4 | |
478b92f0 | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
28f540f4 | 9 | |
478b92f0 UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
28f540f4 | 14 | |
41bdb6e2 AJ |
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. */ | |
28f540f4 RM |
19 | |
20 | #include <hurd.h> | |
a334319f UD |
21 | #include <hurd/signal.h> |
22 | #include <mach/exception.h> | |
10ceac89 | 23 | |
28f540f4 RM |
24 | /* Translate the Mach exception codes, as received in an `exception_raise' RPC, |
25 | into a signal number and signal subcode. */ | |
26 | ||
27 | void | |
a334319f | 28 | _hurd_exception2signal (struct hurd_signal_detail *detail, int *signo) |
28f540f4 | 29 | { |
a334319f | 30 | detail->error = 0; |
28f540f4 | 31 | |
a334319f | 32 | switch (detail->exc) |
28f540f4 RM |
33 | { |
34 | default: | |
35 | *signo = SIGIOT; | |
a334319f | 36 | detail->code = detail->exc; |
28f540f4 | 37 | break; |
a334319f | 38 | |
28f540f4 | 39 | case EXC_BAD_ACCESS: |
a334319f | 40 | if (detail->exc_code == KERN_PROTECTION_FAILURE) |
28f540f4 RM |
41 | *signo = SIGSEGV; |
42 | else | |
43 | *signo = SIGBUS; | |
a334319f UD |
44 | detail->code = detail->exc_subcode; |
45 | detail->error = detail->exc_code; | |
28f540f4 RM |
46 | break; |
47 | ||
48 | case EXC_BAD_INSTRUCTION: | |
49 | *signo = SIGILL; | |
a334319f UD |
50 | if (detail->exc_code == EXC_MIPS_II) |
51 | detail->code = detail->exc_subcode; | |
52 | else | |
53 | detail->code = 0; | |
28f540f4 | 54 | break; |
a334319f | 55 | |
28f540f4 | 56 | case EXC_ARITHMETIC: |
a334319f UD |
57 | switch (detail->exc_code) |
58 | { | |
59 | case EXC_MIPS_OV: /* integer overflow */ | |
60 | *signo = SIGFPE; | |
61 | detail->code = detail->exc_subcode; | |
62 | break; | |
63 | ||
64 | default: | |
65 | *signo = SIGFPE; | |
66 | detail->code = 0; | |
67 | break; | |
68 | ||
69 | case EXC_MIPS_INT: | |
70 | /* Subcode is the fp_status word saved by the hardware. | |
71 | Give an error code corresponding to the first bit set. */ | |
72 | if (detail->exc_subcode == EXC_MIPS_FLT_UNIMP) | |
73 | *signo = SIGILL; | |
74 | else | |
75 | *signo = SIGFPE; | |
76 | detail->code = detail->exc_subcode; | |
77 | break; | |
78 | } | |
28f540f4 RM |
79 | break; |
80 | ||
a334319f UD |
81 | case EXC_EMULATION: |
82 | /* 3.0 doesn't give this one, why, I don't know. */ | |
28f540f4 | 83 | *signo = SIGEMT; |
a334319f | 84 | detail->code = 0; |
28f540f4 | 85 | break; |
478b92f0 | 86 | |
a334319f UD |
87 | case EXC_SOFTWARE: |
88 | *signo = SIGEMT; | |
89 | detail->code = 0; | |
90 | break; | |
91 | ||
28f540f4 RM |
92 | case EXC_BREAKPOINT: |
93 | *signo = SIGTRAP; | |
a334319f | 94 | detail->code = 0; |
28f540f4 RM |
95 | break; |
96 | } | |
97 | } |