]>
Commit | Line | Data |
---|---|---|
28f540f4 RM |
1 | /* Translate Mach exception codes into signal numbers. Stub version. |
2 | Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. | |
3 | This file is part of the GNU C Library. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Library General Public License as | |
7 | published by the Free Software Foundation; either version 2 of the | |
8 | License, or (at your option) any later version. | |
9 | ||
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 | Library General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Library General Public | |
16 | License along with the GNU C Library; see the file COPYING.LIB. If | |
17 | not, write to the Free Software Foundation, Inc., 675 Mass Ave, | |
18 | Cambridge, MA 02139, USA. */ | |
19 | ||
20 | #include <hurd.h> | |
21 | ||
22 | /* Translate the Mach exception codes, as received in an `exception_raise' RPC, | |
23 | into a signal number and signal subcode. */ | |
24 | ||
25 | void | |
26 | _hurd_exception2signal (int exception, int code, int subcode, | |
27 | int *signo, int *sigcode, int *error) | |
28 | { | |
29 | *error = 0; | |
30 | ||
31 | switch (exception) | |
32 | { | |
33 | default: | |
34 | *signo = SIGIOT; | |
35 | *sigcode = exception; | |
36 | break; | |
37 | ||
38 | case EXC_BAD_ACCESS: | |
39 | if (code == KERN_PROTECTION_FAILURE) | |
40 | *signo = SIGSEGV; | |
41 | else | |
42 | *signo = SIGBUS; | |
43 | *sigcode = subcode; | |
44 | *error = code; | |
45 | break; | |
46 | ||
47 | case EXC_BAD_INSTRUCTION: | |
48 | *signo = SIGILL; | |
49 | *sigcode = 0; | |
50 | break; | |
51 | ||
52 | case EXC_ARITHMETIC: | |
53 | *signo = SIGFPE; | |
54 | *sigcode = 0; | |
55 | break; | |
56 | ||
57 | case EXC_EMULATION: | |
58 | case EXC_SOFTWARE: | |
59 | *signo = SIGEMT; | |
60 | *sigcode = 0; | |
61 | break; | |
62 | ||
63 | case EXC_BREAKPOINT: | |
64 | *signo = SIGTRAP; | |
65 | *sigcode = 0; | |
66 | break; | |
67 | } | |
68 | } |